0

I am trying to covert the below oracle MERGE statement to equivalent in PostgreSQL.

Oracle query:

MERGE INTO dest a
    USING source b
    ON (a.id = b.id)
  WHEN MATCHED THEN
    UPDATE SET a.code        = b.code,
               a.description = b.description
  WHEN NOT MATCHED THEN
    INSERT (id, code, description)
    VALUES (b.id, b.code, b.description)
  LOG ERRORS INTO err$_dest ('MERGE') REJECT LIMIT UNLIMITED;

Equivalent for the above merge statement:

INSERT INTO dest (id, code, description) 
              SELECT b.id, b.code, b.description
              FROM source b           
ON CONFLICT (id) DO UPDATE SET 
code        = EXCLUDED.code,
description = EXCLUDED.description;

Can somebody explain how to find equivalent for this clause

LOG ERRORS INTO err$_dest ('MERGE') REJECT LIMIT UNLIMITED;
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.