Module org.jooq
Package org.jooq

Interface InsertReturningStep<R extends Record>

All Superinterfaces:
Attachable, AttachableQueryPart, DMLQuery<R>, Flow.Publisher<Integer>, Insert<R>, InsertFinalStep<R>, Publisher<Integer>, org.reactivestreams.Publisher<Integer>, Query, QueryPart, RowCountQuery, Serializable, Statement
All Known Subinterfaces:
InsertOnConflictConditionStep<R>, InsertOnConflictWhereStep<R>, InsertOnDuplicateSetMoreStep<R>, InsertOnDuplicateStep<R>, InsertSetMoreStep<R>, InsertValuesStep1<R,T1>, InsertValuesStep10<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>, InsertValuesStep11<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>, InsertValuesStep12<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>, InsertValuesStep13<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>, InsertValuesStep14<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>, InsertValuesStep15<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>, InsertValuesStep16<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>, InsertValuesStep17<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>, InsertValuesStep18<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>, InsertValuesStep19<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>, InsertValuesStep2<R,T1,T2>, InsertValuesStep20<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>, InsertValuesStep21<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>, InsertValuesStep22<R,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>, InsertValuesStep3<R,T1,T2,T3>, InsertValuesStep4<R,T1,T2,T3,T4>, InsertValuesStep5<R,T1,T2,T3,T4,T5>, InsertValuesStep6<R,T1,T2,T3,T4,T5,T6>, InsertValuesStep7<R,T1,T2,T3,T4,T5,T6,T7>, InsertValuesStep8<R,T1,T2,T3,T4,T5,T6,T7,T8>, InsertValuesStep9<R,T1,T2,T3,T4,T5,T6,T7,T8,T9>, InsertValuesStepN<R>

public interface InsertReturningStep<R extends Record> extends InsertFinalStep<R>
This type is used for the Insert's DSL API.

Example:

 
 DSLContext create = DSL.using(configuration);

 TableRecord<?> record =
 create.insertInto(table, field1, field2)
       .values(value1, value2)
       .returning(field1)
       .fetchOne();
 
 

This implemented differently for every dialect:

Note that if jOOQ cannot fetch any identity value in your given dialect because 1) there is no native SQL syntax or 2) there is no identity column, or 3) there is no support for fetching any identity values, then the INSERT … RETURNING statement will simply not produce any rows!

Referencing XYZ*Step types directly from client code

It is usually not recommended to reference any XYZ*Step types directly from client code, or assign them to local variables. When writing dynamic SQL, creating a statement's components dynamically, and passing them to the DSL API statically is usually a better choice. See the manual's section about dynamic SQL for details: https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql.

Drawbacks of referencing the XYZ*Step types directly:

  • They're operating on mutable implementations (as of jOOQ 3.x)
  • They're less composable and not easy to get right when dynamic SQL gets complex
  • They're less readable
  • They might have binary incompatible changes between minor releases
Author:
Lukas Eder