insertIgnore

inline fun <T : Table> T.insertIgnore(crossinline body: T.(UpdateBuilder<*>) -> Unit): InsertStatement<Long>

Represents the SQL statement that inserts a new row into a table, while ignoring any possible errors that occur during the process.

For example, if the new row would violate a unique constraint, its insertion would be ignored. Note: INSERT IGNORE is not supported by all vendors. Please check the documentation.

Samples

org.jetbrains.exposed.sql.tests.shared.dml.InsertTests.testInsertIgnoreAndGetIdWithPredefinedId
fun <T : Table> T.insertIgnore(selectQuery: AbstractQuery<*>, columns: List<Column<*>> = this.columns.filter { it.isValidIfAutoIncrement() }): Int?

Represents the SQL statement that uses data retrieved from a selectQuery to insert new rows into a table, while ignoring any possible errors that occur during the process.

Note: INSERT IGNORE is not supported by all vendors. Please check the documentation.

Return

The number of inserted rows, or null if nothing was retrieved after statement execution.

Parameters

selectQuery

Source SELECT query that provides the values to insert.

columns

Columns to insert the values into. This defaults to all columns in the table that are not auto-increment columns without a valid sequence to generate new values.