public interface InsertOnDuplicateStep<R extends Record> extends InsertReturningStep<R>
Insert's DSL API.
Example:
DSLContext create = DSL.using(configuration);
create.insertInto(table, field1, field2)
.values(value1, value2)
.values(value3, value4)
.onDuplicateKeyUpdate()
.set(field1, value1)
.set(field2, value2)
.execute();
| Modifier and Type | Method and Description |
|---|---|
InsertFinalStep<R> |
onDuplicateKeyIgnore()
Add an
ON DUPLICATE KEY IGNORE clause to this insert query. |
InsertOnDuplicateSetStep<R> |
onDuplicateKeyUpdate()
Add an
ON DUPLICATE KEY UPDATE clause to this insert query. |
returning, returning, returningbind, bind, cancel, close, execute, getBindValues, getParam, getParams, getSQL, getSQL, getSQL, isExecutable, keepStatement, queryTimeoutattach, detach@Support(value={CUBRID,DB2,HSQLDB,INFORMIX,MARIADB,MYSQL,ORACLE,SQLSERVER,SYBASE}) InsertOnDuplicateSetStep<R> onDuplicateKeyUpdate()
ON DUPLICATE KEY UPDATE clause to this insert query.
This will try to INSERT a record. If there is a primary key
or unique key in this INSERT statement's affected table that
matches the value being inserted, then the UPDATE clause is
executed instead.
MySQL and CUBRID natively implements this type of clause. jOOQ can
simulate this clause using a MERGE statement on some other
databases. The conditions for a RDBMS to simulate this clause are:
INSERT statement's table is a
Table with a Table.getPrimaryKey()MERGE clause (see
DSLContext.mergeInto(Table)).These are the dialects that fulfill the above requirements:
@Support(value={CUBRID,DB2,HSQLDB,INFORMIX,MARIADB,MYSQL,ORACLE,SQLSERVER,SYBASE}) InsertFinalStep<R> onDuplicateKeyIgnore()
ON DUPLICATE KEY IGNORE clause to this insert query.
This will try to INSERT a record. If there is a primary key
or unique key in this INSERT statement's affected table that
matches the value being inserted, then the INSERT statement
is ignored.
This clause is not actually supported in this form by any database, but can be simulated as such:
| Dialect | Simulation |
|---|---|
SQLDialect.MARIADB |
|
SQLDialect.MYSQL |
|
SQLDialect.CUBRID |
|
SQLDialect.DB2SQLDialect.HSQLDBSQLDialect.ORACLESQLDialect.SQLSERVERSQLDialect.SYBASE |
|
Copyright © 2015. All Rights Reserved.