Search Postgresql Archives

Re: Trigger help - updates to column data with null values

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

 



Greg Fischer wrote:
> Hello all!
> I do my best to read and google my way around issues, but I seem to be
> missing something. Probably simple too.
> 
> So I have a trigger function, in which I'd like to check if a particular
> column has changed.  It works great, unless either the OLD or NEW values
> are NULL.  The purpose is to create a audit/log of the record.  I prefer
> to only test for certain columns, not the whole table.
> 
> 
> CREATE OR REPLACE FUNCTION tr_employees_bu()
>   RETURNS trigger AS
> $BODY$
> begin
> if (new.trainingdate <> old.trainingdate) then

Instead, try the test:

   new.trainingdate IS DISTINCT FROM old.trainingdate

See the manual for 'IS DISTINCT FROM'.

--
Craig Ringer

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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