private void generateColumnsFromQuery() {
   int columnCount = asQuery.getColumnCount();
   ArrayList<Expression> expressions = asQuery.getExpressions();
   for (int i = 0; i < columnCount; i++) {
     Expression expr = expressions.get(i);
     int type = expr.getType();
     String name = expr.getAlias();
     long precision = expr.getPrecision();
     int displaySize = expr.getDisplaySize();
     DataType dt = DataType.getDataType(type);
     if (precision > 0
         && (dt.defaultPrecision == 0
             || (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) {
       // dont' set precision to MAX_VALUE if this is the default
       precision = dt.defaultPrecision;
     }
     int scale = expr.getScale();
     if (scale > 0
         && (dt.defaultScale == 0 || (dt.defaultScale > scale && dt.defaultScale < precision))) {
       scale = dt.defaultScale;
     }
     if (scale > precision) {
       precision = scale;
     }
     Column col = new Column(name, type, precision, scale, displaySize);
     addColumn(col);
   }
 }
 /**
  * Returns the parameter type. java.sql.Types.VARCHAR is returned if the data type is not known.
  *
  * @param param the column index (1,2,...)
  * @return the data type
  */
 public int getParameterType(int param) throws SQLException {
   try {
     debugCodeCall("getParameterType", param);
     ParameterInterface p = getParameter(param);
     int type = p.getType();
     if (type == Value.UNKNOWN) {
       type = Value.STRING;
     }
     return DataType.getDataType(type).sqlType;
   } catch (Exception e) {
     throw logAndConvert(e);
   }
 }
示例#3
0
 @Override
 public int getScale() {
   return DataType.getDataType(dataType).defaultScale;
 }
示例#4
0
 public int getScale() {
   return DataType.getDataType(getType()).defaultScale;
 }