Thanks for the heads-up on the issue and the workaround!

Alex

On Thursday, January 21, 2016 at 3:22:00 AM UTC-6, Lukas Eder wrote:
>
> Hello Alex,
>
> I'm afraid there's no easy way to do this right now with jOOQ. There's a 
> pending feature request for this functionality:
> https://github.com/jOOQ/jOOQ/issues/4474
>
> You can always resort to plain SQL and templating, though. E.g.
>
> Table<?> moved = table(name("moved_rows"));
>
> Query delete = delete(PRODUCTS).where(...).returning();
>
> Query insert = insertInto(PRODUCTS_LOG).select(select().from(moved));
>
> ctx.execute("WITH {0} AS ({1}) {2}", moved, delete, insert);
>
>
> Hope this helps,
> Lukas
>
> 2016-01-21 1:45 GMT+01:00 Alex Wenckus <awen...@nuve.us <javascript:>>:
>
>> I am attempting to use the Postgres with keyword to modify multiple 
>> tables, with the results of one feeding into the other. This seems to be 
>> possible with the default Postgres syntax:
>>
>>
>> http://www.postgresql.org/docs/current/interactive/queries-with.html#QUERIES-WITH-MODIFYING
>>
>> WITH moved_rows AS (
>>     DELETE FROM products
>>     WHERE
>>         "date" >= '2010-10-01' AND
>>         "date" < '2010-11-01'
>>     RETURNING *
>> )
>> INSERT INTO products_log
>> SELECT * FROM moved_rows;
>>
>>
>> But it appears as the JOOQ DSL only supports SELECTs inside of a WITH. Is 
>> there any way I can coerce an insert statement to a select for the purposes 
>> of using it inside of a with? Or is there something else I can do?
>>
>> Thanks!
>> Alex
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jooq-user+...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to