Re: insert on conflict postgres returning distinction - Mailing list pgsql-general

From pinker
Subject Re: insert on conflict postgres returning distinction
Date
Msg-id 1597258357335-0.post@n3.nabble.com
Whole thread Raw
In response to Re: insert on conflict postgres returning distinction  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: insert on conflict postgres returning distinction  (pinker <pinker@onet.eu>)
List pgsql-general
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 gucio
where xmax = (select xmax_value from txmaxu where xmax_value <> 0 limit 1);



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html



pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Sizing PostgreSQL VM server sizing
Next
From: pinker
Date:
Subject: Re: insert on conflict postgres returning distinction