| From: | SZUCS Gábor <surrano(at)mailbox(dot)hu> | 
|---|---|
| To: | <pgsql-sql(at)postgresql(dot)org> | 
| Subject: | Re: Triggers - need help !!! | 
| Date: | 2004-07-08 11:19:28 | 
| Message-ID: | 005801c464dd$72b5bec0$0403a8c0@fejleszt4 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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(at)archonet(dot)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
>   ...
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gerwin Philippo | 2004-07-08 12:53:29 | Re: append columns that are null | 
| Previous Message | SZŰCS Gábor | 2004-07-08 11:09:54 | Constraint->function dependency and dump in 7.3 |