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
> ...