Re: UPDATE ... ON CONFLICT DO NOTHING

From: Yasin Sari <yasinsari81(at)googlemail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: UPDATE ... ON CONFLICT DO NOTHING
Date: 2017-03-14 19:07:40
Message-ID: CADhAfgOMA7UkHRKe=ECD0jftT9oyEXzcZWriLQiDFBcKck5QeQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Have you tried with inner block and do nothing on exception;

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

END;

<your code>
..............

END;

14 Mar 2017 Sal, 19:01 tarihinde, Alexander Farber <
alexander(dot)farber(at)gmail(dot)com> şunu yazdı:

> My initial idea has been not to use ON CONFLICT at all, but instead only
> UPDATE the words_reviews records (set "uid" or "author" to out_uid) for
> which NO EXISTS already such a record with PK (uid, author)... and then
> DELETE the rest (as I can't update them without a conflict) but I haven't
> figured it out yet...
>
> Thank you anyway
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lawrence Cohan 2017-03-14 19:31:37 Postgres backup solution
Previous Message Adrian Klaver 2017-03-14 18:18:09 Re: UPDATE ... ON CONFLICT DO NOTHING