insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS>> method

BatchedStatement insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS>>(
  1. GeneratedTable<Row, RS> table,
  2. BaseSelectStatement<BaseSelectStatement, dynamic> select, {
  3. required Map<TableColumn<Object>, Expression<Object>> columns,
  4. 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:

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);
}