From: SZUCS Gábor <surrano@mailbox.hu>
To: pgsql-sql@postgresql.org
Subject: Re: Triggers - need help !!!
Date: Thu, 8 Jul 2004 13:19:28 +0200
Message-ID: <005801c464dd$72b5bec0$0403a8c0@fejleszt4> (raw)
References: <77ED2BF75D59D1439F90412CC5B109740E8A2E38@ie10-sahara.hiso.honeywell.com>
<40EBD891.3050205@archonet.com>
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
> ...
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: surrano@mailbox.hu
Subject: Re: Triggers - need help !!!
In-Reply-To: <005801c464dd$72b5bec0$0403a8c0@fejleszt4>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox