Re: problem with on conflict / do update using psql 14.4 - Mailing list pgsql-general

From Christophe Pettus
Subject Re: problem with on conflict / do update using psql 14.4
Date
Msg-id 1E5122A4-E58F-40C3-B579-A0BBD8FFE065@thebuild.com
Whole thread Raw
In response to Re: problem with on conflict / do update using psql 14.4  (Barry Kimelman <blkimelman@gmail.com>)
List pgsql-general

> On Sep 24, 2022, at 09:04, Barry Kimelman <blkimelman@gmail.com> wrote:
> Unfortunately, that is exactly what I need to do, I need to modify the data on the 2nd request so that it also gets
inserted.

The best approach is to optimistically insert the row, catch the error if there's a conflict, and modify the data and
tryagain.  If a row with the same conflict can come from multiple sessions, you'll need to decide how to handle the
casethat some other session "wins" and inserts the row, and you get a conflict again. 




pgsql-general by date:

Previous
From: Barry Kimelman
Date:
Subject: Re: problem with on conflict / do update using psql 14.4
Next
From: "David G. Johnston"
Date:
Subject: Re: problem with on conflict / do update using psql 14.4