DeleteStatement

Represents a builder for constructing and executing a SQL DELETE statement.

This interface provides a fluent API to build a DELETE query by chaining methods like where(), orderBy(), and limit(). The query is executed by calling either execute() or executeReturning().

Instances of this interface are created via the KQLiteTable.delete() extension function.

Example:

// Create a DELETE statement
val statement = MyTable.delete()

// Build the query and execute it
statement
.where { it.status EQ "inactive" }
.orderBy(MyTable.lastLogin, Sort.ASC)
.limit(100)
.execute()

Author

MOHAMMAD AZIM ANSARI

Type Parameters

T

The type of the KQLiteTable from which rows will be deleted.

See also

Functions

Link copied to clipboard
abstract fun execute()

Executes the DELETE statement.

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

Executes the DELETE statement and returns a KQLiteCursor containing the data from the deleted rows, as specified by the RETURNING clause.

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

Same as calling limit(limit, -1)

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

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

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

Same as calling orderBy(column, null)

abstract fun orderBy(column: KQLiteColumn<*>, sort: Sort?): DeleteStatement<T>
abstract fun orderBy(orderColumn1: OrderColumn, orderColumn2: OrderColumn?): DeleteStatement<T>

Adds an ORDER BY clause to the DELETE statement, which is used in conjunction with LIMIT.

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

Adds a WHERE clause to the DELETE statement.