Re: Trigger with conditional predicates

Поиск
Список
Период
Сортировка
От Christophe Pettus
Тема Re: Trigger with conditional predicates
Дата
Msg-id 7097609B-DCC8-49B8-932C-35A3D7D6A405@thebuild.com
обсуждение исходный текст
Ответ на Trigger with conditional predicates  (Dirk Mika <Dirk.Mika@mikatiming.de>)
Ответы Re: Trigger with conditional predicates  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Trigger with conditional predicates  (Dirk Mika <Dirk.Mika@mikatiming.de>)
Список pgsql-general

> On Jan 1, 2021, at 07:56, Dirk Mika <Dirk.Mika@mikatiming.de> wrote:
> In particular, columns are populated with values if they are not specified in the update statement which is used.
> Usually with an expression like this:
>
>      IF NOT UPDATING('IS_CANCELED')
>      THEN
>         :new.is_canceled := ...;
>      END IF;
>
> I have not found anything similar in PostgreSQL. What is the common approach to this problem?

PostgreSQL doesn't have an exact equivalent.  Typically, the OLD and NEW values are compared and then action is taken
basedon that.  For example, in PL/pgSQL: 

IF NEW.is_canceled IS NOT DISTINCT FROM OLD.is_canceled THEN
    NEW.is_canceled := etc etc ;
ENDIF;

There's currently no way to detect if the column was simply not mentioned at all in the UPDATE statement.

--
-- Christophe Pettus
   xof@thebuild.com




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

Предыдущее
От: Dirk Mika
Дата:
Сообщение: Trigger with conditional predicates
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Trigger with conditional predicates