api-docs / org.ktorm.dsl / batchUpdate
batchUpdate
fun <T : BaseTable<*>> Database.batchUpdate(
table: T,
block: BatchUpdateStatementBuilder<T>.() -> Unit
): IntArray
(source code)Construct update expressions in the given closure, then batch execute them and return the effected
row counts for each expression.
Note that this function is implemented based on Statement.addBatch and Statement.executeBatch,
and any item in a batch operation must have the same structure, otherwise an exception will be thrown.
Usage:
database.batchUpdate(Departments) {
for (i in 1..2) {
item {
set(it.location, "Hong Kong")
where {
it.id eq i
}
}
}
}
Parameters
table
- the table to be updated.
block
- the DSL block, extension function of BatchUpdateStatementBuilder, used to construct the expressions.
Since
2.7
Return
the effected row counts for each sub-operation.