ON CONFLICT DO NOTHING RETURNING - Mailing list pgsql-general

From Peter Devoy
Subject ON CONFLICT DO NOTHING RETURNING
Date
Msg-id CABoFc_hxX7F9n_nTGFP5-9y-Qy5v9_Wgn5j4DSaD8q-Gx0g=6w@mail.gmail.com
Whole thread Raw
Responses Re: ON CONFLICT DO NOTHING RETURNING  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-general
Hi all

Is it possible to have ON CONFLICT DO NOTHING RETURNING or must I use DO UPDATE?

E.g. if the 'name' column of my 'animals' table is unique it seems a little silly having to do an arbitrary update to get an ID from the row:

INSERT INTO animals (name) VALUES ('dog') ON CONFLICT (name) DO UPDATE SET name='dog' RETURNING animal_id;

Is there a reason DO NOTHING was not developed for use with RETURNING?

Either way, upsert is great, I am glad we have it now.

Kind regards


Peter Devoy

pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: Suppress decimal point like digits in to_char?
Next
From: Merlin Moncure
Date:
Subject: Re: Unexpected result using floor() function