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

From Alexander Farber
Subject Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING
Date
Msg-id CAADeyWhNYKZ2TFn7zcsbQqZGV0TiUZkLvsJrWnre+oNguqeW6g@mail.gmail.com
Whole thread Raw
In response to [GENERAL] UPDATE ... ON CONFLICT DO NOTHING  (Alexander Farber <alexander.farber@gmail.com>)
Responses Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING
Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING
List pgsql-general
I have come up with the following (when trying to merge array _uids to a single out_uid):

                -- try to copy as many reviews of this user as possible
                INSERT INTO words_reviews (
                        uid,
                        author,
                        nice,
                        review,
                        updated
                ) SELECT
                        out_uid,
                        author,
                        nice,
                        review,
                        updated
                FROM words_reviews
                WHERE uid <> out_uid
                AND uid = ANY(_uids)
                ON CONFLICT DO NOTHING;

                DELETE FROM words_reviews
                WHERE uid <> out_uid
                AND uid = ANY(_uids);

                -- try to copy as many reviews by this user as possible
                INSERT INTO words_reviews (
                        uid,
                        author,
                        nice,
                        review,
                        updated
                ) SELECT
                        uid,
                        out_uid,
                        nice,
                        review,
                        updated
                FROM words_reviews
                WHERE author <> out_uid
                AND author = ANY(_uids)
                ON CONFLICT DO NOTHING;

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [GENERAL] PostgreSQL general discussions list - 2010 Thread:Wikipedia entry - AmigaOS port - error?
Next
From: Glyn Astill
Date:
Subject: Re: [GENERAL] Table not cleaning up drom dead tuples