Want to migrate your vendor-specific PostgreSQL INSERT .. ON CONFLICT to vendor-specific SQL Server MERGE statements? No problemo with jOOQ
Conversation
Replying to
They're not the same thing, though. MERGE doesn't provide any guarantees about getting an insert or an update outcome: wiki.postgresql.org/wiki/UPSERT#ME. The fact that it uses a join makes it more flexible in other ways, though.
1
2
Replying to
Yes, that's a good point - although, it's probably the closest we can get to emulating ON CONFLICT with standard SQL (and it's totally acceptable in the absence of concurrency)
1
Replying to
I guess it is, unless you can use subtransactions. Note that there was a MERGE feature committed to Postgres 11 (it was reverted, though). The general Postgres view was always that it makes sense to have MERGE alongside ON CONFLICT. The semantics of each are fairly different.
Replying to
I reviewed the MERGE patch, and am not the author. I think that it probably will be resubmitted, though.
1

