问题
Is it possible to create a INSERT INTO ... SELECT ... RETURNING
statement with jOOQ? If so, how?
There is no returning
function here:
context.insertInto(table, list of fields).select(select statement).returning()
If this is indeed absent, is there a smart workaround available? I cannot express my INSERT INTO ... SELECT ...
as a INSERT INTO ... VALUES ...
. See question jOOQ - multi-field for insertion for more details about the query.
回答1:
That combination of INSERT
keywords was indeed not possible until jOOQ 3.7 via #3779.
A workaround in the meantime would be to use plain SQL:
Result<Record> result = context.fetch("{0} returning *", insertInto(...).select(...));
来源:https://stackoverflow.com/questions/32028601/jooq-insert-into-select-returning