withStatement

open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

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

The function should always be short-lived, consider using withTransaction 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

statementFunction

The function to run with the prepared statement

See also


open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, readOnly: Boolean, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

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

The function should always be short-lived, consider using withTransaction 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

statementFunction

The function to run with the prepared statement

See also


open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, columnIndexes: @NotNull Array<Int>, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

The returned keys are accessible using getGeneratedKeys().

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

The function should always be short-lived, consider using withTransaction 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

columnIndexes

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

statementFunction

The function to run with the prepared statement

See also


open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, readOnly: Boolean, columnIndexes: @NotNull Array<Int>, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

The returned keys are accessible using getGeneratedKeys().

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

The function should always be short-lived, consider using withTransaction 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 index indicating the columns that should be returned from the inserted row or rows

statementFunction

The function to run with the prepared statement

See also


open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, @NotNull columnNames: @NotNull Array<@NotNull String>, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

The returned keys are accessible using getGeneratedKeys().

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

The function should always be short-lived, consider using withTransaction 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

columnNames

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

statementFunction

The function to run with the prepared statement

See also


open fun <R, E : Exception?> withStatement(@NotNull @Language(value = "PostgreSQL") sql: @NotNull String, readOnly: Boolean, @NotNull columnNames: @NotNull Array<@NotNull String>, @NotNull statementFunction: @NotNull StatementFunction<R, E>): R(source)

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

The returned keys are accessible using getGeneratedKeys().

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

The function should always be short-lived, consider using withTransaction 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

statementFunction

The function to run with the prepared statement

See also