limit

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.

This is used to constrain the number of rows affected by the UPDATE operation. It is almost always used in conjunction with an ORDER BY clause to ensure that the updates are applied to a predictable subset of rows.

Note: The LIMIT clause in an UPDATE statement is a non-standard SQLite extension.

Example

// Give a bonus to the 10 most recently hired employees who don't have one yet.
Employees
.update { ... }
.orderBy(...)
.limit(10)
.execute()

// Update the next 10 employees (skipping the first 10)
Employees
.update { ... }
.orderBy(...)
.limit(10, offset = 10)
.execute()

Return

The UpdateStatement instance for further chaining.

Author

MOHAMMAD AZIM ANSARI

Parameters

limit

The maximum number of rows to update. A negative value means no limit.

offset

The number of rows to skip before starting to update. A negative or zero value means no offset.

See also