Re: Triggers - need help !!! - Mailing list pgsql-sql

From SZUCS Gábor
Subject Re: Triggers - need help !!!
Date
Msg-id 005801c464dd$72b5bec0$0403a8c0@fejleszt4
Whole thread Raw
In response to Re: Triggers - need help !!!  ("Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>)
Responses Newbie (to postgres) question  ("Pedro B." <pedro.borracha@netcabo.pt>)
List pgsql-sql
I'd like to add that a NULL value might mess things up. If CreateTime may be
null, try this:
 if (OLD.CreateTime <> NEW.CreateTime) OR    (OLD.CreateTime ISNULL <> NEW.CreateTime ISNULL) THEN ...

or this:
 if COALESCE(OLD.CreateTime, '3001-01-01') <>    COALESCE(NEW.CreateTime, '3001-01-01') THEN ...

(provided you can safely assume that createtimes remain in this millenium
;) )

or maybe:
 if COALESCE(OLD.CreateTime <> NEW.CreateTime,             OLD.CreateTime ISNULL <> NEW.CreateTime ISNULL) THEN ...

However; I'd stay with the first one. It's quite simple and Y3K-safe ;)
Also, it seems to be the most effective of them, if any.

G.
%----------------------- cut here -----------------------%
\end

----- Original Message ----- 
From: "Richard Huxton" <dev@archonet.com>
Sent: Wednesday, July 07, 2004 1:03 PM


> Pradeepkumar, Pyatalo (IE10) wrote:
> > Thanks a lot for ur help.
> >  In the trigger, I am checking if a field is updated or not. The syntax
I
> > use is
> >
> > IF UPDATE(CreateTime) THEN
> > ....
> > ....
> > END IF;
> >
> > Is this syntax correct.
>
> No, and I don't recall seeing anything like it in the manuals.
>
> IF OLD.CreateTime <> NEW.CreateTime THEN
>   ...



pgsql-sql by date:

Previous
From: "SZŰCS Gábor"
Date:
Subject: Constraint->function dependency and dump in 7.3
Next
From: "Pedro B."
Date:
Subject: Newbie (to postgres) question