1

Im using the on conflict clause of Postgresql to achieve something like an "upsert", like this:

INSERT INTO person (id, name)
VALUES (1, 'alice')
ON CONFLICT (id)
DO UPDATE SET name = 'alice'
RETURNING id;

the table looks like this

 CREATE TABLE person (id serial primary key, name text not null);

I now would like to know when i execute the above insert query, whether it was performed as an insert or an update.

Is there a way to return something like this:

...
RETURNING id, no_conflict_insert
keppla
  • 31
  • 2

0 Answers0