SQLiteStatement



SQLite statement definition.

A prepared statement is a resource that must be released once it is no longer needed via its close function.

See also Prepared Statement

Summary

Public functions

Unit
bindBlob(index: @IntRange(from = 1) Int, value: ByteArray)

Binds a ByteArray value to this statement at an index.

Cmn
android
JS
Unit
bindBoolean(index: @IntRange(from = 1) Int, value: Boolean)

Binds a Boolean value to this statement at an index.

Cmn
android
JS
Unit
bindDouble(index: @IntRange(from = 1) Int, value: Double)

Binds a Double value to this statement at an index.

Cmn
android
JS
Unit
bindFloat(index: @IntRange(from = 1) Int, value: Float)

Binds a Float value to this statement at an index.

Cmn
android
JS
Unit
bindInt(index: @IntRange(from = 1) Int, value: Int)

Binds a Int value to this statement at an index.

Cmn
android
JS
Unit
bindLong(index: @IntRange(from = 1) Int, value: Long)

Binds a Long value to this statement at an index.

Cmn
android
JS
Unit
bindNull(index: @IntRange(from = 1) Int)

Binds a NULL value to this statement at an index.

Cmn
android
JS
Unit
bindText(index: @IntRange(from = 1) Int, value: String)

Binds a String value to this statement at an index.

Cmn
android
JS
Unit

Clears all parameter bindings.

Cmn
android
JS
Unit

Closes the statement.

Cmn
android
JS
ByteArray
getBlob(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a ByteArray.

Cmn
android
JS
Boolean
getBoolean(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a Boolean.

Cmn
android
JS
Int

Returns the number of columns in the result of the statement.

Cmn
android
JS
String
getColumnName(index: @IntRange(from = 0) Int)

Returns the name of a column at index in the result of the statement.

Cmn
android
JS
List<String>

Returns the name of the columns in the result of the statement ordered by their index.

Cmn
android
JS
Int
getColumnType(index: @IntRange(from = 0) Int)

Returns the data type of a column at index in the result of the statement.

Cmn
android
JS
Double
getDouble(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a Double.

Cmn
android
JS
Float
getFloat(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a Float.

Cmn
android
JS
Int
getInt(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a Int.

Cmn
android
JS
Long
getLong(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a Long.

Cmn
android
JS
String
getText(index: @IntRange(from = 0) Int)

Returns the value of the column at index as a String.

Cmn
android
JS
Boolean
isNull(index: @IntRange(from = 0) Int)

Returns true if the value of the column at index is NULL.

Cmn
android
JS
Unit

Resets the prepared statement back to initial state so that it can be re-executed via step.

Cmn
android
JS
Boolean

Executes the statement and evaluates the next result row if available.

android
suspend Boolean

Executes the statement asynchronously and evaluates the next result row if available.

Cmn
JS

Extension functions

suspend Boolean

Executes the statement asynchronously and evaluates the next result row if available.

Cmn
android
JS

Public functions

bindBlob

fun bindBlob(index: @IntRange(from = 1) Int, value: ByteArray): Unit

Binds a ByteArray value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: ByteArray

the value to bind

bindBoolean

fun bindBoolean(index: @IntRange(from = 1) Int, value: Boolean): Unit

Binds a Boolean value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: Boolean

the value to bind

bindDouble

fun bindDouble(index: @IntRange(from = 1) Int, value: Double): Unit

Binds a Double value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: Double

the value to bind

bindFloat

fun bindFloat(index: @IntRange(from = 1) Int, value: Float): Unit

Binds a Float value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: Float

the value to bind

bindInt

fun bindInt(index: @IntRange(from = 1) Int, value: Int): Unit

Binds a Int value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: Int

the value to bind

bindLong

fun bindLong(index: @IntRange(from = 1) Int, value: Long): Unit

Binds a Long value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: Long

the value to bind

bindNull

fun bindNull(index: @IntRange(from = 1) Int): Unit

Binds a NULL value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

bindText

fun bindText(index: @IntRange(from = 1) Int, value: String): Unit

Binds a String value to this statement at an index.

Parameters
index: @IntRange(from = 1) Int

the 1-based index of the parameter to bind

value: String

the value to bind

clearBindings

fun clearBindings(): Unit

Clears all parameter bindings. Unset bindings are treated as NULL.

close

fun close(): Unit

Closes the statement.

Once a statement is closed it should no longer be used. Calling this function on an already closed statement is a no-op.

getBlob

fun getBlob(index: @IntRange(from = 0) Int): ByteArray

Returns the value of the column at index as a ByteArray.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
ByteArray

the value of the column

getBoolean

fun getBoolean(index: @IntRange(from = 0) Int): Boolean

Returns the value of the column at index as a Boolean.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Boolean

the value of the column

getColumnCount

fun getColumnCount(): Int

Returns the number of columns in the result of the statement.

Returns
Int

the number of columns

getColumnName

fun getColumnName(index: @IntRange(from = 0) Int): String

Returns the name of a column at index in the result of the statement.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
String

the name of the column

getColumnNames

fun getColumnNames(): List<String>

Returns the name of the columns in the result of the statement ordered by their index.

Returns
List<String>

the names of the columns

getColumnType

fun getColumnType(index: @IntRange(from = 0) Int): Int

Returns the data type of a column at index in the result of the statement.

The data type can be used to determine the preferred get*() function to be used for the column but other getters may perform data type conversion.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Int

the data type of the column

getDouble

fun getDouble(index: @IntRange(from = 0) Int): Double

Returns the value of the column at index as a Double.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Double

the value of the column

getFloat

fun getFloat(index: @IntRange(from = 0) Int): Float

Returns the value of the column at index as a Float.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Float

the value of the column

getInt

fun getInt(index: @IntRange(from = 0) Int): Int

Returns the value of the column at index as a Int.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Int

the value of the column

getLong

fun getLong(index: @IntRange(from = 0) Int): Long

Returns the value of the column at index as a Long.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Long

the value of the column

getText

fun getText(index: @IntRange(from = 0) Int): String

Returns the value of the column at index as a String.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
String

the value of the column

isNull

fun isNull(index: @IntRange(from = 0) Int): Boolean

Returns true if the value of the column at index is NULL.

Parameters
index: @IntRange(from = 0) Int

the 0-based index of the column

Returns
Boolean

true if the column value is NULL, false otherwise

reset

fun reset(): Unit

Resets the prepared statement back to initial state so that it can be re-executed via step. Any parameter bound via the bind*() APIs will retain their value.

step

fun step(): Boolean

Executes the statement and evaluates the next result row if available.

A statement is initially prepared and compiled but is not executed until one or more calls to this function. If the statement execution produces result rows then this function will return true indicating there is a new row of data ready to be read.

Returns
Boolean

true if there are more rows to evaluate or false if the statement is done executing

stepAsync

suspend fun stepAsync(): Boolean

Executes the statement asynchronously and evaluates the next result row if available.

A statement is initially prepared and compiled but is not executed until one or more calls to this function. If the statement execution produces result rows then this function will return true indicating there is a new row of data ready to be read.

Returns
Boolean

true if there are more rows to evaluate or false if the statement is done executing

Extension functions

step

suspend fun SQLiteStatement.step(): Boolean

Executes the statement asynchronously and evaluates the next result row if available.

On web targets this function is asynchronous while for non-web it is synchronous.