X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9DA49D1B19F for ; Thu, 8 Jul 2004 08:19:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81555-05 for ; Thu, 8 Jul 2004 11:20:00 +0000 (GMT) Received: from fe09.axelero.hu (fe09.axelero.hu [195.228.240.97]) by svr1.postgresql.org (Postfix) with ESMTP id C3D7CD1B18F for ; Thu, 8 Jul 2004 08:19:55 -0300 (ADT) Received: from fe09 (localhost-02 [127.0.2.1]) by fe09.axelero.hu (8.12.11/8.12.11) with SMTP id i68BK3Ub075843 for ; Thu, 8 Jul 2004 13:20:04 +0200 (CEST) Received: from fe09.axelero.hu [127.0.2.1] via SMTP gateway by fe09 [195.228.240.97]; id A0270EA8EBE at Thu, 08 Jul 2004 13:19:58 +0200 Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu [81.182.248.121]) by fe09.axelero.hu (8.12.11/8.12.11) with SMTP id i68BJpho075242 for ; Thu, 8 Jul 2004 13:19:55 +0200 (CEST) Message-ID: <005801c464dd$72b5bec0$0403a8c0@fejleszt4> From: =?ISO-8859-1?Q?SZUCS_G=E1bor?= To: References: <77ED2BF75D59D1439F90412CC5B109740E8A2E38@ie10-sahara.hiso.honeywell.com> <40EBD891.3050205@archonet.com> Subject: Re: Triggers - need help !!! Date: Thu, 8 Jul 2004 13:19:28 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-RAVMilter-Version: 8.4.3(snapshot 20030217) (fe09.axelero.hu) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.3 tagged_above=0.0 required=5.0 tests=PLING_PLING X-Spam-Level: * X-Archive-Number: 200407/33 X-Sequence-Number: 18285 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" 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 > ...