org.jooq
Interface InsertOnDuplicateStep

All Superinterfaces:
Adapter, Attachable, Insert, InsertFinalStep, Query, QueryPart, Serializable
All Known Subinterfaces:
InsertSetMoreStep, InsertValuesStep

public interface InsertOnDuplicateStep
extends InsertFinalStep

This type is used for the Insert's DSL API.

Example:

 Factory create = new Factory();

 create.insertInto(table, field1, field2)
       .values(value1, value2)
       .values(value3, value4)
       .onDuplicateKeyUpdate()
       .set(field1, value1)
       .set(field2, value2)
       .execute();
 

Author:
Lukas Eder

Method Summary
 InsertOnDuplicateSetStep onDuplicateKeyUpdate()
          Add an ON DUPLICATE KEY UPDATE clause to this insert query.
 
Methods inherited from interface org.jooq.Query
execute
 
Methods inherited from interface org.jooq.QueryPart
getSQL
 
Methods inherited from interface org.jooq.Attachable
attach, getConfiguration
 
Methods inherited from interface org.jooq.Adapter
internalAPI
 

Method Detail

onDuplicateKeyUpdate

InsertOnDuplicateSetStep onDuplicateKeyUpdate()
Add an 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 is the only database that natively implements this type of clause. Some other databases simulate this clause using a MERGE statement. The conditions for a RDBMS to simulate this clause are:

These are the dialects that fulfill the above requirements:



Copyright © 2011. All Rights Reserved.