Пример #1
0
 protected Row createRow(Value[] values) {
   Row newRow = table.getTemplateRow();
   for (int j = 0; j < columns.length; j++) {
     Column c = columns[j];
     int index = c.getColumnId();
     Value v = c.convert(values[j]);
     newRow.setValue(index, v);
   }
   return newRow;
 }
Пример #2
0
 private ValueResultSet getTable(
     Session session, Expression[] argList, boolean onlyColumnList, boolean distinctRows) {
   int len = columnList.length;
   Expression[] header = new Expression[len];
   Database db = session.getDatabase();
   for (int i = 0; i < len; i++) {
     Column c = columnList[i];
     ExpressionColumn col = new ExpressionColumn(db, c);
     header[i] = col;
   }
   LocalResult result = new LocalResult(session, header, len);
   if (distinctRows) {
     result.setDistinct();
   }
   if (!onlyColumnList) {
     Value[][] list = new Value[len][];
     int rows = 0;
     for (int i = 0; i < len; i++) {
       Value v = argList[i].getValue(session);
       if (v == ValueNull.INSTANCE) {
         list[i] = new Value[0];
       } else {
         ValueArray array = (ValueArray) v.convertTo(Value.ARRAY);
         Value[] l = array.getList();
         list[i] = l;
         rows = Math.max(rows, l.length);
       }
     }
     for (int row = 0; row < rows; row++) {
       Value[] r = new Value[len];
       for (int j = 0; j < len; j++) {
         Value[] l = list[j];
         Value v;
         if (l.length <= row) {
           v = ValueNull.INSTANCE;
         } else {
           Column c = columnList[j];
           v = l[row];
           v = c.convert(v);
           v = v.convertPrecision(c.getPrecision(), false);
           v = v.convertScale(true, c.getScale());
         }
         r[j] = v;
       }
       result.addRow(r);
     }
   }
   result.done();
   ValueResultSet vr = ValueResultSet.get(getSimpleResultSet(result, Integer.MAX_VALUE));
   return vr;
 }
Пример #3
0
 protected Row createRow(Expression[] expr, int rowId) {
   Row newRow = table.getTemplateRow();
   for (int i = 0, len = columns.length; i < len; i++) {
     Column c = columns[i];
     int index = c.getColumnId();
     Expression e = expr[i];
     if (e != null) {
       // e can be null (DEFAULT)
       try {
         Value v = c.convert(e.getValue(session));
         newRow.setValue(index, v);
       } catch (DbException ex) {
         throw setRow(ex, rowId, getSQL(expr));
       }
     }
   }
   return newRow;
 }