# batchReplace

fun <T : Table, E : Any> T.batchReplace(data: Iterable<E>, shouldReturnGeneratedValues: Boolean = true, body: BatchReplaceStatement.(E) -> Unit): List<ResultRow>

Represents the SQL statement that either batch inserts new rows into a table, or, if insertions violate unique constraints, first deletes the existing rows before inserting new rows.

Note: This operation is not supported by all vendors, please check the documentation.

#### Parameters

data

Collection of values to use in replace.

shouldReturnGeneratedValues

Specifies whether newly generated values (for example, auto-incremented IDs) should be returned. See Batch Insert for more details.

#### Samples

org.jetbrains.exposed.sql.tests.shared.dml.ReplaceTests.testBatchReplace01

fun <T : Table, E : Any> T.batchReplace(data: Sequence<E>, shouldReturnGeneratedValues: Boolean = true, body: BatchReplaceStatement.(E) -> Unit): List<ResultRow>

Represents the SQL statement that either batch inserts new rows into a table, or, if insertions violate unique constraints, first deletes the existing rows before inserting new rows.

Note: This operation is not supported by all vendors, please check the documentation.

#### Parameters

data

Sequence of values to use in replace.

shouldReturnGeneratedValues

Specifies whether newly generated values (for example, auto-incremented IDs) should be returned. See Batch Insert for more details.

#### Samples

org.jetbrains.exposed.sql.tests.shared.dml.ReplaceTests.testBatchReplaceWithSequence