Hello,

> Mysql Auto Increment
> ------------------------------
> I would like to insert a set of records on a table containing
> autogenerated keys. Is there any way of getting multiple autogenerated
> keys when using
> insert into t values(..).values(..).

Fetching several ID values from multi-record insert statements is now
supported with jOOQ 1.6.6. The DSL syntax to achieve this behaviour is
this:

Result<?> result = create
    .insertInto(MY_TABLE, MyTable.COL1, MyTable.COL2)
    .values(1, "a")
    .values(2, "b")
    .values(3, "c")
    .returning(MyTable.ID)
    .fetch();

This currently works for DB2, HSQLDB, MySQL, and Postgres. Other JDBC
drivers don't seem to fully support selecting several generated keys.
See the manual for more info about INSERT support in jOOQ:

https://sourceforge.net/apps/trac/jooq/wiki/Manual/JOOQ/Query

Reply via email to