If nothing else, anyone needing MERGE can port their MERGE statements to
a DML with DML-containing CTEs...
The generic mapping would be something like this, I think:
WITH rows AS (SELECT <target> FROM <target> WHERE <condition>) , updated AS ( UPDATE <target> SET ... WHERE
<key>IN (SELECT <key> FROM rows) /* matched */ RETURNING <target> ) , inserted AS ( INSERT INTO <target> SELECT
... WHERE <key> NOT IN (SELECT <key> FROM rows) /* not matched */ RETURNING <target> )
DELETE FROM <target>
WHERE (...) AND <key> NOT IN (SELECT <key> FROM updated UNION SELECT <key> FROM inserted);
Nico
--
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers