Re: Reg: Firing Trigger when a particular column value get changed - Mailing list pgsql-sql

From sad
Subject Re: Reg: Firing Trigger when a particular column value get changed
Date
Msg-id 200309220921.56092.sad@bankir.ru
Whole thread Raw
In response to Re: Reg: Firing Trigger when a particular column value get changed  (Kevin Houle <kevin@houle.org>)
List pgsql-sql
On Sunday 21 September 2003 02:38, you wrote:
> Thilak babu wrote:
> >   I have a scnerio as to fire a trigger when i update a particular column
> > in a table. Please do help me out in getting thro this.
>
> The trigger function can use logic to exclude cases where a particular
> column does not change. For example:
>
> CREATE FUNCTION "column_update" () RETURNS TRIGGER AS '
>    BEGIN
>      IF ( NEW.column <> OLD.column ) THEN
>        do-your-stuff-here;
>      END IF;
>    RETURN NEW;
> END; ' LANGUAGE 'plpgsql';

this trigger will not execute "your-stuff-here"
if NEW.column or OLD.column will be null.
you need to add this case to the logic statement in the "IF"

(NEW.column <> OLD.column) OR (NEW.column IS NULL <> OLD.column. IS NULL)




pgsql-sql by date:

Previous
From: sad
Date:
Subject: Re: auto_increment
Next
From: "NAGAPPA"
Date:
Subject: selecting duplicate records