Re: How to UPSERT with optional updates?

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: How to UPSERT with optional updates?
Дата
Msg-id CAH2-WzmoPqRxyFxDR_W8oeyRp4i3r05F295ELRKovRA_uA=GJQ@mail.gmail.com
обсуждение исходный текст
Ответ на How to UPSERT with optional updates?  (Utku <ugultopu@gmail.com>)
Список pgsql-novice
On Tue, Sep 21, 2021 at 9:58 AM Utku <ugultopu@gmail.com> 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



В списке pgsql-novice по дате отправления:

Предыдущее
От: Utku
Дата:
Сообщение: How to UPSERT with optional updates?
Следующее
От: Terry Buchanan
Дата:
Сообщение: Is a Digest Version of this List Available?