Re: insert on conflict postgres returning distinction

From: pinker <pinker(at)onet(dot)eu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: insert on conflict postgres returning distinction
Date: 2020-08-12 18:52:37
Message-ID: 1597258357335-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pinker 2020-08-12 20:13:42 Re: insert on conflict postgres returning distinction
Previous Message Michael Lewis 2020-08-12 16:50:45 Re: Sizing PostgreSQL VM server sizing