execute

abstract fun execute(): KQLiteCursor

Same as calling execute(null). Uses last opened connection.


abstract fun execute(connection: SQLiteConnection?): KQLiteCursor

Executes a simple SELECT query that does not require a FROM clause.

This is useful for queries that operate on literals or built-in SQL functions, such as retrieving the current date/time or performing simple calculations.

Example

// Get the current UTC dateTime
val cursor = select(DATETIME("now")).execute()
val currentDateTime = cursor.getString(0)
cursor.close()

// Perform a calculation
select(MAX(IntLiteral(10), IntLiteral(20))).execute()

// Select specific columns
select(Users.id, Users.name).from(Users).execute()

If the query needs to retrieve data from a table, use the from method instead.

Return

A KQLiteCursor containing the result set of the query. The caller is responsible for closing the cursor.

Author

MOHAMMAD AZIM ANSARI

Parameters

connection

An optional SQLiteConnection to use for executing the query. If null, a default connection from KQLiteConnection will be used.

See also