4

I have a table with different columns and I am doing an insert (as upsert) which should update values only in case of conflict:

INSERT INTO clients (name, address, postcode, email)
VALUES ( .... ) 
ON CONFLICT (name, address) 
DO
    UPDATE
    SET email = EXCLUDED.email || ';' || customers.email;

but also I need an extra condition liek ON CONFLICT (address, postcode).

in a sort of:

INSERT INTO clients (name, address, postcode, email)
VALUES ( .... ) 
ON CONFLICT (name, address) OR CONFLICT (address, postcode) -- this is the change I am referring to
DO
    UPDATE
    SET email = EXCLUDED.email || ';' || customers.email;

How can I achieve that as only one conflict can be managed?

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.