onDuplicateKeyUpdate values

23 views
Skip to first unread message

Chen Wu

unread,
Jun 22, 2022, 1:51:14 PM6/22/22
to jOOQ User Group
Hi everyone,

I'm wondering what is the correct syntax for generating a query that has SQL 

on duplicate key update `column_name`=VALUES(`column_name`)

? When I try to use onDuplicateKeyUpdate.set(column_name, column_name) it generates 

on duplicate key update `column_name`=`column_name`

which does not update an existing row with new values when inserting into the table.

Thank you
Chen 

Lukas Eder

unread,
Jun 23, 2022, 3:26:18 AM6/23/22
to jOOQ User Group
Starting with jOOQ 3.17, we've added support for the PostgreSQL EXCLUDED pseudo table, which works just like MySQL's VALUES() clause and emulates itself that way. Use DSL.excluded() for that purpose:

Note that MySQL has deprecated VALUES() and will implement a different syntax in the future, which we'll adopt soon via our EXCLUDED emulation.

I 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/9171bbfe-2872-4e39-860a-cd34d7632ed7n%40googlegroups.com.

Chen Wu

unread,
Jun 23, 2022, 2:16:49 PM6/23/22
to jOOQ User Group
Hi Lukas,

Thank you for your reply. Is there a way to achieve this with version 3.14.9? I'm not able to upgrade jOOQ yet to the latest version.

Thanks,
Chen 

Lukas Eder

unread,
Jun 24, 2022, 2:31:11 AM6/24/22
to jOOQ User Group

Chen Wu

unread,
Jun 24, 2022, 3:39:14 AM6/24/22
to jOOQ User Group
Got it. Thank you!
Reply all
Reply to author
Forward
0 new messages