# upsert

open fun upsert(table: Table, data: List<Pair<Column<*>, Any?>>, expression: String, onUpdate: List<Pair<Column<*>, Any?>>, keyColumns: List<Column<*>>, where: Op<Boolean>?, transaction: Transaction): String

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

Note: Vendors that do not support this operation directly implement the standard MERGE USING command.

#### Parameters

table

Table to either insert values into or update values from.

data

Pairs of columns to use for insert or update and values to insert or update.

expression

Expression with the values to use in the insert clause.

onUpdate

List of pairs of specific columns to update and the expressions to update them with.

keyColumns

Columns to include in the condition that determines a unique constraint match.

where

Condition that determines which rows to update, if a unique violation is found.

transaction

Transaction where the operation is executed.