insert where not exists

626 views
Skip to first unread message

Mohit Jaggi

unread,
Jul 3, 2014, 4:09:50 PM7/3/14
to jooq...@googlegroups.com
Hi Fellow Jooqers,
I did not find an example for the jooq way to "insert into T values (u, v) where not exists select..". Is that possible to do in jooq?

Mohit.

Lukas Eder

unread,
Jul 9, 2014, 4:17:45 AM7/9/14
to jooq...@googlegroups.com, Mohit Jaggi
Hello Mohit,

I'm sorry for the delay. I was on a quick time off on Kos island...

Your query is most certainly possible, but the SQL syntax you have in mind is not valid. The INSERT .. VALUES statement does not allow for additional predicates, you will have to use the INSERT .. SELECT statement, i.e.

    INSERT INTO t
    SELECT u, v
    FROM ...
    WHERE NOT EXISTS ...

A short example can be seen in the manual:

Hope this helps,
Lukas



--
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.
For more options, visit https://groups.google.com/d/optout.

Mohit Jaggi

unread,
Jul 9, 2014, 9:59:06 AM7/9/14
to Lukas Eder, jooq...@googlegroups.com
Lukas,
Thanks and hope you had a good break. I have one more question:
Can I do 
SELECT "Jack", 10, 20 FROM ....
in jooq?
I thought I could only use this construct if I am selecting 1
SELECT 1 FROM ...

Mohit.

Reply all
Reply to author
Forward
0 new messages