jOOQ - INSERT INTO … SELECT … RETURNING

点点圈 提交于 2019-12-14 03:57:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!