# MergeStatement

abstract class MergeStatement(val table: Table) : Statement<Int>

The base implementation of SQL merge command that is used by statements like MergeSelectStatement, MergeTableStatement

#### Inheritors

MergeTableStatement
MergeSelectStatement

## Constructors

MergeStatement
Link copied to clipboard
constructor(table: Table)

## Types

Clause
Link copied to clipboard
data class Clause(val type: MergeStatement.ClauseCondition, val action: MergeStatement.ClauseAction, val arguments: List<Pair<Column<*>, Any?>>, val and: Op<Boolean>?, val deleteWhere: Op<Boolean>? = null, val overridingSystemValue: Boolean = false, val overridingUserValue: Boolean = false)
ClauseAction
Link copied to clipboard
enum ClauseAction : Enum<MergeStatement.ClauseAction>
ClauseCondition
Link copied to clipboard
enum ClauseCondition : Enum<MergeStatement.ClauseCondition>

## Properties

table
Link copied to clipboard
val table: Table

The destination Table where records will be merged into.

targets
Link copied to clipboard
val targets: List<Table>
type
Link copied to clipboard
val type: StatementType

## Functions

arguments
Link copied to clipboard
open override fun arguments(): Iterable<Iterable<Pair<IColumnType<*>, Any?>>>

Returns all mappings of columns and expression types to their values needed to prepare an SQL statement.

prepareSQL
Link copied to clipboard
abstract fun prepareSQL(transaction: Transaction, prepared: Boolean = true): String

Returns the string representation of an SQL statement.

whenMatchedDelete
Link copied to clipboard
fun whenMatchedDelete(and: Op<Boolean>? = null)

Specifies a delete operation to be executed when a matching record is found in the destination table.

whenMatchedDoNothing
Link copied to clipboard
fun whenMatchedDoNothing(and: Op<Boolean>? = null)

Postgres only. Specifies that no operation should be performed when a matching record is found in the destination table.

whenMatchedUpdate
Link copied to clipboard
fun whenMatchedUpdate(and: Op<Boolean>? = null, deleteWhere: Op<Boolean>? = null, body: (UpdateStatement) -> Unit)

Defines an update operation to be executed when a matching record is found in the destination table.

whenNotMatchedDoNothing
Link copied to clipboard
fun whenNotMatchedDoNothing(and: Op<Boolean>? = null)

Postgres only. Specifies that no operation should be performed when no matching record is found in the destination table.

whenNotMatchedInsert
Link copied to clipboard
fun whenNotMatchedInsert(and: Op<Boolean>? = null, overridingUserValue: Boolean = false, overridingSystemValue: Boolean = false, body: (InsertStatement<Int>) -> Unit)

Defines an insert operation to be performed when there is no matching record in the destination table.