I would like to express the following INSERT
statement:
context.insertInto(TABLE A)
.set(<FIELD A, FIELD B>, context.select(FIELD A, FIELD B).from(B).where(...))
.set(... other field of table A ...)
.set(... other field of table A ...)
.set(... other field of table A ...)
.returning()
.fetch()
The sub-select returns one row with two columns (FIELD A
and FIELD B
) which need to be inserted into the target TABLE A
. The reason for this is that <FIELD A, FIELD B>
is the primary key of TABLE B
. TABLE A
is refering to TABLE B
(foreign key).
Is this possible?