executeReturning

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.

This function allows you to retrieve values from the rows that were just deleted. It is useful for logging, auditing, or obtaining IDs of the deleted records.

Note: The RETURNING clause is only supported in SQLite version 3.35.0 and newer. Using this function on older versions of SQLite will result in a runtime error.

Example:

// Delete inactive users and get their IDs and email addresses
val deletedUsersCursor = MyTable.delete()
.where { it.status EQ "inactive" }
.executeReturning(MyTable.id, MyTable.email)

// Iterate through the deleted users' data
for (row in deletedUsersCursor) {
val id = row[MyTable.id]
val email = row[MyTable.email]
println("Deleted user with ID: $id, Email: $email")
}
deletedUsersCursor.close()

Return

A KQLiteCursor that can be iterated over to access the data from the deleted rows. The cursor must be closed after use to release resources.

Author

MOHAMMAD AZIM ANSARI

Parameters

columns

A variable number of KQLiteColumn instances to be returned for each deleted row. If no columns are provided, it may behave like execute() or throw an error, depending on the implementation.

See also