English | 简体中文

api-docs / org.ktorm.dsl / update

update

fun <T : BaseTable<*>> Database.update(
    table: T,
    block: UpdateStatementBuilder.(T) -> Unit
): Int
(source code)

Construct an update expression in the given closure, then execute it and return the effected row count.

Usage:

database.update(Employees) {
set(it.job, "engineer")
set(it.managerId, null)
set(it.salary, 100)
where {
it.id eq 2
}
}

Parameters

table - the table to be updated.

block - the DSL block, an extension function of UpdateStatementBuilder, used to construct the expression.

Since
2.7

Return
the effected row count.