preparedStatement

inline suspend fun <R> Database.preparedStatement(@Language(value = "PostgreSQL") sql: String, readOnly: Boolean = false, generatedKeys: Boolean = false, block: SuspendingPreparedStatement.() -> R): R(source)

Creates a statement from the given SQL statement, runs the block, commits the changes and closes the connection.

The returned keys are accessible using getGeneratedKeys.

If all connections are used, this function suspends until a connection is available.

The block should always be short-lived, consider using transactional otherwise.

Supports nesting, but it is not recommended doing so, avoid nesting by returning the data as soon as possible.

Parameters

sql

An SQL statement that may contain one or more '?' IN parameter placeholders

readOnly

true if the database only is read from, can allow some optimizations but does not prevent writing

generatedKeys

true to return the generated keys

See also


inline suspend fun <R> Database.preparedStatement(@Language(value = "PostgreSQL") sql: String, readOnly: Boolean = false, columnIndexes: IntArray, block: SuspendingPreparedStatement.() -> R): R(source)

Creates a statement from the given SQL statement, runs the block, commits the changes and closes the connection.

The returned keys are accessible using getGeneratedKeys.

If all connections are used, this function suspends until a connection is available.

The block should always be short-lived, consider using transactional otherwise.

Supports nesting, but it is not recommended doing so, avoid nesting by returning the data as soon as possible.

Parameters

sql

An SQL statement that may contain one or more '?' IN parameter placeholders

readOnly

true if the database only is read from, can allow some optimizations but does not prevent writing

columnIndexes

An array of column indexes indicating the columns that should be returned from the inserted row or rows

See also


inline suspend fun <R> Database.preparedStatement(@Language(value = "PostgreSQL") sql: String, readOnly: Boolean = false, columnNames: Array<out String>, block: SuspendingPreparedStatement.() -> R): R(source)

Creates a statement from the given SQL statement, runs the block, commits the changes and closes the connection.

The returned keys are accessible using getGeneratedKeys.

If all connections are used, this function suspends until a connection is available.

The block should always be short-lived, consider using transactional otherwise.

Supports nesting, but it is not recommended doing so, avoid nesting by returning the data as soon as possible.

Parameters

sql

An SQL statement that may contain one or more '?' IN parameter placeholders

readOnly

true if the database only is read from, can allow some optimizations but does not prevent writing

columnNames

An array of column names indicating the columns that should be returned from the inserted row or rows

See also