Source:
<code>private int insertRows() { session.getUser().checkRight(table, Right.INSERT); setCurrentRowNumber(0); table.fire(session, Trigger.INSERT, true); rowNumber = 0; int listSize = list.size(); if (listSize > 0) { int columnLen = columns.length; GeneratedKeys generatedKeys = session.getGeneratedKeys(); generatedKeys.initialize(table); for (int x = 0; x < listSize; x++) { session.startStatementWithinTransaction(); generatedKeys.nextRow(); Row newRow = table.getTemplateRow(); Expression[] expr = list.get(x); setCurrentRowNumber(x + 1); for (int i = 0; i < columnLen; i++) { Column c = columns[i]; int index = c.getColumnId(); Expression e = expr[i]; if (e != null) { e = e.optimize(session); try { Value v = c.convert(e.getValue(session), session.getDatabase().getMode()); newRow.setValue(index, v); if (e instanceof SequenceValue) { generatedKeys.add(c); } } catch (DbException ex) { throw setRow(ex, x, getSQL(expr)); } } } rowNumber++; table.validateConvertUpdateSequence(session, newRow); boolean done = table.fireBeforeRow(session, null, newRow); if (!done) { table.lock(session, true, false); try { table.addRow(session, newRow); } catch (DbException de) { if (!handleOnDuplicate(de)) { rowNumber--; continue; } } <START> generatedKeys.confirmRow(newRow); <END> session.log(table, UndoLogRecord.INSERT, newRow); table.fireAfterRow(session, null, newRow, false); } } } else { table.lock(session, true, false); if (insertFromSelect) { query.query(0, this); } else { ResultInterface rows = query.query(0); while (rows.next()) { Value[] r = rows.currentRow(); addRow(r); } rows.close(); } } table.fire(session, Trigger.INSERT, false); return rowNumber; }</code><technical_language>[this case](<LINK_0>, need autogenerated keys for INSERT ... SELECT ...</technical_language>

Target:
private int insertRows() { session.getUser().checkRight(table, Right.INSERT); setCurrentRowNumber(0); table.fire(session, Trigger.INSERT, true); rowNumber = 0; GeneratedKeys generatedKeys = session.getGeneratedKeys(); generatedKeys.initialize(table); int listSize = list.size(); if (listSize > 0) { int columnLen = columns.length; for (int x = 0; x < listSize; x++) { session.startStatementWithinTransaction(); generatedKeys.nextRow(); Row newRow = table.getTemplateRow(); Expression[] expr = list.get(x); setCurrentRowNumber(x + 1); for (int i = 0; i < columnLen; i++) { Column c = columns[i]; int index = c.getColumnId(); Expression e = expr[i]; if (e != null) { e = e.optimize(session); try { Value v = c.convert(e.getValue(session), session.getDatabase().getMode()); newRow.setValue(index, v); if (e instanceof SequenceValue) { generatedKeys.add(c); } } catch (DbException ex) { throw setRow(ex, x, getSQL(expr)); } } } rowNumber++; table.validateConvertUpdateSequence(session, newRow); boolean done = table.fireBeforeRow(session, null, newRow); if (!done) { table.lock(session, true, false); try { table.addRow(session, newRow); } catch (DbException de) { if (!handleOnDuplicate(de)) { rowNumber--; continue; } } generatedKeys.confirmRow(newRow); session.log(table, UndoLogRecord.INSERT, newRow); table.fireAfterRow(session, null, newRow, false); } } } else { table.lock(session, true, false); if (insertFromSelect) { query.query(0, this); } else { ResultInterface rows = query.query(0); while (rows.next()) { generatedKeys.nextRow(); Value[] r = rows.currentRow(); Row newRow = addRowImpl(r); if (newRow != null) { generatedKeys.confirmRow(newRow); } } rows.close(); } } table.fire(session, Trigger.INSERT, false); return rowNumber; }