public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Geoghegan <[email protected]>
To: Utku <[email protected]>
Cc: [email protected]
Subject: Re: How to UPSERT with optional updates?
Date: Tue, 21 Sep 2021 10:02:54 -0700
Message-ID: <CAH2-WzmoPqRxyFxDR_W8oeyRp4i3r05F295ELRKovRA_uA=GJQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Tue, Sep 21, 2021 at 9:58 AM Utku <[email protected]> wrote:
> I'm trying to write a script for an optional upsert. That is, it is just like a regular insert or update, but in addition, the information of a given column should be updated, or be left as-is, is passed as well. That is:
>
> - Insert if does not exist.
> - If exists, check the parameters to understand if a particular column should be updated, or be left as-is.
The DO UPDATE portion of an upsert statement will accept a WHERE
clause that works in much the same way as a WHERE clause from a
regular UPDATE. You can decide whether you really want to update the
row, based on the row's actual contents, as well as the contents of
your EXCLUDED.* pseudo-row.
--
Peter Geoghegan
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How to UPSERT with optional updates?
In-Reply-To: <CAH2-WzmoPqRxyFxDR_W8oeyRp4i3r05F295ELRKovRA_uA=GJQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox