ResultColumnList rcl = insertNode.getTargetColumnList();
int ncols = insertNode.getResultSetNode().getResultColumns().size();
List<Column> targetColumns;
if (rcl != null) {
if (ncols != rcl.size())
throw new InsertWrongCountException(rcl.size(), ncols);
targetColumns = new ArrayList<>(rcl.size());
for (ResultColumn resultColumn : rcl) {
Column column = getColumnReferenceColumn(resultColumn.getReference(),
"Unsupported target column");
targetColumns.add(column);
}
}
else {
// No explicit column list: use DDL order.
List<Column> aisColumns = targetTable.getTable().getColumns();
if (ncols > aisColumns.size())
throw new InsertWrongCountException(aisColumns.size(), ncols);
targetColumns = new ArrayList<>(ncols);
for (int i = 0; i < ncols; i++) {
targetColumns.add(aisColumns.get(i));
}
}