insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS> > method
BatchedStatement
insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS> >(
- GeneratedTable<
Row, RS> table, - BaseSelectStatement<
BaseSelectStatement, dynamic> select, { - required Map<
TableColumn< columns,Object> , Expression<Object> > - UpsertClause<
Row, RS> ? onConflict,
Inserts rows from the select statement.
This method creates an INSERT INTO SELECT statement in SQL which will
insert a row into this table for each row returned by the select
statement.
The columns map describes which column from the select statement should
be written into which column of the table. The keys of the map are the
target column, and values are expressions added to the select statement.
See also:
- InsertStatement.fromSelect, which would be used outside a Batch.
Implementation
BatchedStatement
insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS>>(
GeneratedTable<Row, RS> table,
BaseSelectStatement select, {
required Map<TableColumn, Expression> columns,
UpsertClause<Row, RS>? onConflict,
}) {
final stmt = InsertStatement<Row, RS>(database, table)
..fromSelect(select, columns: columns);
if (onConflict != null) {
stmt.onConflict(onConflict);
}
return addStatement(stmt);
}