Re: insert on conflict postgres returning distinction

2020-08-12 Thread pinker
Od course inside transaction block -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: insert on conflict postgres returning distinction

2020-08-12 Thread pinker
how about this solution? Does it have any caveats? WITH upsert AS (INSERT INTO GUCIO (ID, NAZWA) SELECT A.ID, A.NAZWA FROM ALA A ON CONFLICT (ID) DO UPDATE SET nazwa = excluded.nazwa RETURNING xmax,xmin, *) select xmax as xmax_value into txmaxu from upsert; delete from

Re: insert on conflict postgres returning distinction

2020-08-12 Thread pinker
thank you Adrian, the background of it is that I have already written the python script that translates Oracle MERGE clause to Postgres INSERT ... ON CONFLICT, but in order to be able to add DELETE part from MERGE i need to distinct those operations. thank you for the idea with trigger, i

Re: insert on conflict postgres returning distinction

2020-08-12 Thread Adrian Klaver
On 8/12/20 7:23 AM, pinker wrote: is there any way to distinct between updated and inserted rows in RETURNING clause when ON CONFLICT UPDATE was used? Do you want to use that information immediately in the query or store it somewhere? If the first case I don't think that is possible. For the