# StatementBuilder

interface StatementBuilder

Represents all the DSL methods available when building SQL statements.

## Functions

batchInsert
Link copied to clipboard
open fun <T : Table, E> T.batchInsert(ignoreErrors: Boolean = false, shouldReturnGeneratedValues: Boolean = true, body: BatchInsertStatement.(E) -> Unit): BatchInsertStatement

Represents the SQL statement that batch inserts new rows into a table.

batchReplace
Link copied to clipboard
open fun <T : Table, E : Any> T.batchReplace(shouldReturnGeneratedValues: Boolean = true, body: BatchReplaceStatement.(E) -> Unit): BatchReplaceStatement

Represents the SQL statement that either batch inserts new rows into a table, or, if insertions violate unique constraints, first deletes the existing rows before inserting new rows.

batchUpsert
Link copied to clipboard
open fun <T : Table, E> T.batchUpsert(onUpdateList: List<Pair<Column<*>, Any?>>? = null, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, shouldReturnGeneratedValues: Boolean = true, vararg keys: Column<*>, body: BatchUpsertStatement.(E) -> Unit): BatchUpsertStatement

Represents the SQL statement that either batch inserts new rows into a table, or updates the existing rows if insertions violate unique constraints.

delete
Link copied to clipboard
open fun Join.delete(targetTable: Table, vararg targetTables: Table, ignore: Boolean = false, limit: Int? = null, where: () -> Op<Boolean>? = null): DeleteStatement

Represents the SQL statement that deletes rows from a table in a join relation.

deleteAll
Link copied to clipboard
open fun <T : Table> T.deleteAll(): DeleteStatement

Represents the SQL statement that deletes all rows in a table.

deleteIgnoreWhere
Link copied to clipboard
open fun <T : Table> T.deleteIgnoreWhere(limit: Int? = null, op: T.() -> Op<Boolean>): DeleteStatement

Represents the SQL statement that deletes only rows in a table that match the provided op, while ignoring any possible errors that occur during the process.

deleteReturning
Link copied to clipboard
open fun <T : Table> T.deleteReturning(returning: List<Expression<*>> = columns, where: () -> Op<Boolean>? = null): ReturningStatement

Represents the SQL statement that deletes rows in a table and returns specified data from the deleted rows.

deleteWhere
Link copied to clipboard
open fun <T : Table> T.deleteWhere(limit: Int? = null, op: T.() -> Op<Boolean>): DeleteStatement

Represents the SQL statement that deletes only rows in a table that match the provided op.

insert
Link copied to clipboard
open fun <T : Table> T.insert(body: T.(InsertStatement<Number>) -> Unit): InsertStatement<Number>

Represents the SQL statement that inserts a new row into a table.

open fun <T : Table> T.insert(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): InsertSelectStatement

Represents the SQL statement that uses data retrieved from a selectQuery to insert new rows into a table.

insertIgnore
Link copied to clipboard
open fun <T : Table> T.insertIgnore(body: T.(UpdateBuilder<*>) -> Unit): InsertStatement<Long>

Represents the SQL statement that inserts a new row into a table, while ignoring any possible errors that occur during the process.

open fun <T : Table> T.insertIgnore(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): InsertSelectStatement

Represents the SQL statement that uses data retrieved from a selectQuery to insert new rows into a table, while ignoring any possible errors that occur during the process.

insertReturning
Link copied to clipboard
open fun <T : Table> T.insertReturning(returning: List<Expression<*>> = columns, ignoreErrors: Boolean = false, body: T.(InsertStatement<Number>) -> Unit): ReturningStatement

Represents the SQL statement that inserts new rows into a table and returns specified data from the inserted rows.

mergeFrom
Link copied to clipboard
open fun <D : Table, S : Table> D.mergeFrom(source: S, on: () -> Op<Boolean>? = null, body: MergeTableStatement.() -> Unit): MergeTableStatement

Represents the SQL statement that inserts, updates, or deletes records in a target table based on a comparison with a source table.

open fun <T : Table> T.mergeFrom(selectQuery: QueryAlias, on: () -> Op<Boolean>, body: MergeSelectStatement.() -> Unit): MergeSelectStatement

Represents the SQL statement that inserts, updates, or deletes records in a target table based on a comparison with a select query source.

replace
Link copied to clipboard
open fun <T : Table> T.replace(body: T.(UpdateBuilder<*>) -> Unit): ReplaceStatement<Long>

Represents the SQL statement that either inserts a new row into a table, or, if insertion would violate a unique constraint, first deletes the existing row before inserting a new row.

open fun <T : Table> T.replace(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): ReplaceSelectStatement

Represents the SQL statement that uses data retrieved from a selectQuery to either insert a new row into a table, or, if insertion would violate a unique constraint, first delete the existing row before inserting a new row.

update
Link copied to clipboard
open fun <T : Table> T.update(where: () -> Op<Boolean>? = null, limit: Int? = null, body: T.(UpdateStatement) -> Unit): UpdateStatement

Represents the SQL statement that updates rows of a table.

open fun Join.update(where: () -> Op<Boolean>? = null, limit: Int? = null, body: (UpdateStatement) -> Unit): UpdateStatement

Represents the SQL statement that updates rows of a join relation.

updateReturning
Link copied to clipboard
open fun <T : Table> T.updateReturning(returning: List<Expression<*>> = columns, where: () -> Op<Boolean>? = null, body: T.(UpdateStatement) -> Unit): ReturningStatement

Represents the SQL statement that updates rows of a table and returns specified data from the updated rows.

upsert
Link copied to clipboard
open fun <T : Table> T.upsert(vararg keys: Column<*>, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, body: T.(UpsertStatement<Long>) -> Unit): UpsertStatement<Long>

Represents the SQL statement that either inserts a new row into a table, or updates the existing row if insertion would violate a unique constraint.

upsertReturning
Link copied to clipboard
open fun <T : Table> T.upsertReturning(vararg keys: Column<*>, returning: List<Expression<*>> = columns, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, body: T.(UpsertStatement<Long>) -> Unit): ReturningStatement

Represents the SQL statement that either inserts a new row into a table, or updates the existing row if insertion would violate a unique constraint, and also returns specified data from the modified rows.