UpdateStatement

Represents a configurable UPDATE statement in the KQLite DSL.

This interface provides a fluent API to build and execute UPDATE queries. Instances are typically created by calling the update extension function on a KQLiteTable.

It allows for specifying WHERE clauses, ordering, limits, and executing the statement to either perform the update or retrieve the updated rows.

Example Usage:

// Update the salary for all employees in the "Sales" department,
// ordered by their hire date, and limit the update to the first 10.
Employees
.update {
it.salary to (it.salary * 1.1) // 10% raise
}.where { it.department EQ "Sales" }
.orderBy(Employees.hireDate, sort = Sort.DESC)
.limit(10)
.execute()

Author

MOHAMMAD AZIM ANSARI

Type Parameters

T

The type of the KQLiteTable this statement operates on.

See also

Functions

Link copied to clipboard
abstract fun execute()

Executes the final UPDATE statement.

Link copied to clipboard
abstract fun executeReturning(vararg columns: KQLiteColumn<*>): KQLiteCursor

Executes the UPDATE statement and returns a KQLiteCursor containing the specified columns from the rows that were modified.

Link copied to clipboard
abstract fun from(selectStatement: () -> SelectStatement<*>): UpdateStatement<T>

Adds a FROM clause to the UPDATE statement, allowing updates based on values from another query.

Link copied to clipboard
abstract fun limit(limit: Int): UpdateStatement<T>

Adds a LIMIT clause to the UPDATE statement without OFFSET. Same as calling limit(limit, -1)

abstract fun limit(limit: Int, offset: Int): UpdateStatement<T>

Adds a LIMIT and optional OFFSET clause to the UPDATE statement.

Link copied to clipboard
abstract fun orderBy(column: KQLiteColumn<*>): UpdateStatement<T>

Adds an ORDER BY clause to the UPDATE statement for single column and default sorting.

abstract fun orderBy(column: OrderColumn): UpdateStatement<T>

Adds an ORDER BY clause to the UPDATE statement using OrderColumn objects. Same as calling orderBy(column, null)

abstract fun orderBy(column: KQLiteColumn<*>, sort: Sort?): UpdateStatement<T>

Adds an ORDER BY clause to the UPDATE statement.

abstract fun orderBy(orderColumn1: OrderColumn, orderColumn2: OrderColumn?): UpdateStatement<T>

Adds an ORDER BY clause to the UPDATE statement using one or more OrderColumn objects.

Link copied to clipboard
abstract fun where(clause: Clause.(T) -> Unit): UpdateStatement<T>

Adds a WHERE clause to the UPDATE statement.