Multiply ON CONFLICT ON CONSTRAINT

From: Arnold Somogyi <arnold(dot)somogyi(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Multiply ON CONFLICT ON CONSTRAINT
Date: 2017-02-18 00:53:45
Message-ID: CA+gPAuQjPuAH8YgAO7fDv55cZzJMMfWr8uRQ-xgvQ3Pw14Ai4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I wonder if there is a way to add more then one ON CONSTRAINT value.
I have many different unique constraints on my table and I would like to
catch and handle two of them with ON CONFLICT ON CONSTRAINT. And the rest
errors will be handled by the client application.

INSERT INTO table_1 (id, name, value, user_id, description)
VALUES (1, 'name', 'value', null, null)
ON CONFLICT ON CONSTRAINT *table1_pkey, table1_name_key* DO UPDATE
SET value = EXCLUDED.value, user_id = EXCLUDED.user_id, description =
EXCLUDED.description

Regards,
Arnold

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Brosnahan 2017-02-18 02:50:05 Re: PostgreSQL mirroring from RPM install to RPM install-revisited
Previous Message Jeff Janes 2017-02-17 21:05:11 Re: disk writes within a transaction