- Type Parameters:
R- The record type of the table being modified
- All Superinterfaces:
Attachable,AttachableQueryPart,Flow.Publisher<Integer>,Publisher<Integer>,org.reactivestreams.Publisher<Integer>,Query,QueryPart,RowCountQuery,Serializable,Statement
- All Known Subinterfaces:
InsertQuery<R>,UpdateQuery<R>
A query storing objects to the database. This is either an insert or an
update query.
Instances of this type cannot be created directly, only of its subtypes.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescription<T> voidAdd a value to the store statement<T> voidAdd a value to the store statementvoidAdd multiple values to the store statement.@NotNull Result<?> The records holding returned values as specified by any of thesetReturning()methods.The record holding returned values as specified by any of thesetReturning()methods.The records holding returned values as specified by any of thesetReturning()methods.voidAdd values to the store statementvoidConfigure theINSERTorUPDATEstatement to return all fields inR.voidsetReturning(Collection<? extends SelectFieldOrAsterisk> fields) Configure theINSERTorUPDATEstatement to return a list of fields inR.voidsetReturning(Identity<R, ?> identity) Configure theINSERTorUPDATEstatement to return the generated identity value.voidsetReturning(SelectFieldOrAsterisk... fields) Configure theINSERTorUPDATEstatement to return a list of fields inR.Methods inherited from interface org.jooq.Attachable
attach, configuration, detachMethods inherited from interface org.jooq.AttachableQueryPart
getBindValues, getParam, getParams, getSQL, getSQLMethods inherited from interface org.reactivestreams.Publisher
subscribeMethods inherited from interface org.jooq.Query
bind, bind, cancel, execute, executeAsync, executeAsync, isExecutable, keepStatement, poolable, queryTimeout
-
Method Details
-
setRecord
Add values to the store statement- Parameters:
record- The record holding values that are stored by the query
-
addValue
Add a value to the store statement- Parameters:
field- The fieldvalue- The value
-
addValue
Add a value to the store statement- Parameters:
field- The fieldvalue- The value. If value isnull, this results in callingaddValue(Field, Object)with null as a value.
-
addValues
-
setReturning
Configure theINSERTorUPDATEstatement to return all fields inR.- See Also:
-
setReturning
Configure theINSERTorUPDATEstatement to return the generated identity value.- Parameters:
identity- The table's identity- See Also:
-
setReturning
Configure theINSERTorUPDATEstatement to return a list of fields inR.- Parameters:
fields- Fields to be returned- See Also:
-
setReturning
Configure theINSERTorUPDATEstatement to return a list of fields inR.- Parameters:
fields- Fields to be returned- See Also:
-
getReturnedRecord
The record holding returned values as specified by any of thesetReturning()methods.If the insert statement returns several records, this is the same as calling
getReturnedRecords().get(0)This implemented differently for every dialect:
- Firebird and Postgres have native support for
INSERT … RETURNINGandUPDATE … RETURNINGclauses - HSQLDB, Oracle, and DB2 JDBC drivers allow for retrieving any table column as "generated key" in one statement
- Derby, H2, Ingres, MySQL, SQL Server only allow for retrieving IDENTITY column values as "generated key". If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
- Sybase and SQLite allow for retrieving IDENTITY values as
@@identityorlast_inserted_rowid()values. Those values are fetched in a separateSELECTstatement. If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
- Returns:
- The returned value as specified by any of the
setReturning()methods. This may returnnullin case jOOQ could not retrieve any generated keys from the JDBC driver. - See Also:
- Firebird and Postgres have native support for
-
getReturnedRecords
The records holding returned values as specified by any of thesetReturning()methods.This implemented differently for every dialect:
- Firebird and Postgres have native support for
INSERT … RETURNINGandUPDATE … RETURNINGclauses - HSQLDB, Oracle, and DB2 JDBC drivers allow for retrieving any table column as "generated key" in one statement
- Derby, H2, Ingres, MySQL, SQL Server only allow for retrieving IDENTITY column values as "generated key". If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
- Sybase and SQLite allow for retrieving IDENTITY values as
@@identityorlast_inserted_rowid()values. Those values are fetched in a separateSELECTstatement. If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
[#5070] Due to an early API design flaw, this method historically returns the type
R, not a more generic typeRecord. This means that only actual columns inRcan be returned. For a more generic set of column expressions, usegetResult()instead.- Returns:
- The returned values as specified by any of the
setReturning()methods. Note:- Not all databases / JDBC drivers support returning several values on multi-row inserts!
- This may return an empty
Resultin case jOOQ could not retrieve any generated keys from the JDBC driver.
- Firebird and Postgres have native support for
-
getResult
The records holding returned values as specified by any of thesetReturning()methods.This implemented differently for every dialect:
- Firebird and Postgres have native support for
INSERT … RETURNINGandUPDATE … RETURNINGclauses - HSQLDB, Oracle, and DB2 JDBC drivers allow for retrieving any table column as "generated key" in one statement
- Derby, H2, Ingres, MySQL, SQL Server only allow for retrieving IDENTITY column values as "generated key". If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
- Sybase and SQLite allow for retrieving IDENTITY values as
@@identityorlast_inserted_rowid()values. Those values are fetched in a separateSELECTstatement. If other fields are requested, a second statement is issued. Client code must assure transactional integrity between the two statements.
- Returns:
- The returned values as specified by any of the
setReturning()methods. Note:- Not all databases / JDBC drivers support returning several values on multi-row inserts!
- This may return an empty
Resultin case jOOQ could not retrieve any generated keys from the JDBC driver.
- Firebird and Postgres have native support for
-