Search Postgresql Archives

Re: Trigger with conditional predicates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Jan 1, 2021, at 07:56, Dirk Mika <Dirk.Mika@xxxxxxxxxxxxx> 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 based on 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@xxxxxxxxxxxx







[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux