提交 d4d2b4da authored 作者: Thomas Mueller's avatar Thomas Mueller

Linked tables: for DECIMAL column, Oracle reports precision 0 and scale -127. A…

Linked tables: for DECIMAL column, Oracle reports precision 0 and scale -127. A workaround has been implemented.
上级 df440fa7
......@@ -133,6 +133,7 @@ public class TableLink extends Table {
long precision = rs.getInt("COLUMN_SIZE");
precision = convertPrecision(sqlType, precision);
int scale = rs.getInt("DECIMAL_DIGITS");
scale = convertScale(sqlType, scale);
int displaySize = MathUtils.convertLongToInt(precision);
int type = DataType.convertSQLTypeToValueType(sqlType);
Column col = new Column(n, type, precision, scale, displaySize);
......@@ -259,9 +260,15 @@ public class TableLink extends Table {
}
private long convertPrecision(int sqlType, long precision) {
// workaround for an Oracle problem
// the precision reported by Oracle is 7 for a date column
// workaround for an Oracle problem:
// for DATE columns, the reported precision is 7
// for DECIMAL columns, the reported precision is 0
switch (sqlType) {
case Types.DECIMAL:
if (precision == 0) {
precision = 65535;
}
break;
case Types.DATE:
precision = Math.max(ValueDate.PRECISION, precision);
break;
......@@ -275,6 +282,19 @@ public class TableLink extends Table {
return precision;
}
private int convertScale(int sqlType, int scale) {
// workaround for an Oracle problem:
// for DECIMAL columns, the reported precision is -127
switch (sqlType) {
case Types.DECIMAL:
if (scale < 0) {
scale = 32767;
}
break;
}
return scale;
}
private String convertColumnName(String columnName) {
if ((storesMixedCase || storesLowerCase) && columnName.equals(StringUtils.toLowerEnglish(columnName))) {
columnName = StringUtils.toUpperEnglish(columnName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论