Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING
Date
Msg-id CAKFQuwb-XCeQO4gt4p0SGYEAunZugP3T4DBTLsbqUPAo1giZmA@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING  (Yasin Sari <yasinsari81@googlemail.com>)
Responses Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING
List pgsql-general
The convention on these lists is to inline or bottom-post.

On Tue, Mar 14, 2017 at 12:07 PM, Yasin Sari <yasinsari81@googlemail.com> wrote:
​​
Have you tried with inner block and do nothing on exception;


​I suppose that would work - though using an exception path for expected logic is messy - and considerably slower than detection.

After doing something like this the OP would then want to DELETE any remaining records that still have the uid or author with the old value.  Do nothing by itself would just leave them alone.​

 
BEGIN

 <your code>
..............
         BEGIN
         
          UPDATE words_social 
                SET uid = out_uid
                WHERE uid = ANY(_uids);

         EXCEPTION WHEN OTHERS THEN
            --do nothing or write NULL means do nothing
   

​David J.​

pgsql-general by date:

Previous
From: Stuart Bishop
Date:
Subject: Re: [GENERAL] Postgres backup solution
Next
From: Todd Vitello
Date:
Subject: [GENERAL] Test to pgsql-general@postgresql.org