X-Original-To: pgsql-sql@postgresql.org Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id E3D10475CE5 for ; Tue, 11 Mar 2003 10:36:04 -0500 (EST) Received: from p508184bc.dip0.t-ipconnect.de ([80.129.132.188] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18slnU-0002Qd-00 for pgsql-sql@postgresql.org; Tue, 11 Mar 2003 16:36:08 +0100 Message-ID: <3E6E026C.4090407@web.de> Date: Tue, 11 Mar 2003 16:36:12 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: de-de, de, en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: How to notice column changes in trigger References: <3E6CA287.2EE21BFB@rodos.fzk.de> <002001c2e78b$642e6df0$c9c832c0@societykotla> In-Reply-To: <002001c2e78b$642e6df0$c9c832c0@societykotla> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/263 X-Sequence-Number: 12303 Aspire Something wrote: > Hello Christoph Haller , > > > >>>>So you want the trigger executed only if assignments to b and/or c do > > > Do sime thing like this use if /then /esle s block for the problem > > In the first if blick check that b and c is null by the declaration of > IS NULL after that you run the update command as required > > The program code will show as > > create function > CREATE FUNCTION BLAH_FUNCTION() RETURNS "trigger" > AS ' > usual blah blah of declre and all , > > > IF NEW.b IS NULL and NEW.C IS NULL THEN > ROCK BABY > ELSE > Do OTHERWISE > END IF; > more blah blah plpgsql'; > > Sorry, this won't work at all. The NEW will contain the new row contents, and that may well be non-null for columns not mentioned in the update query. This kind of code will perform well on inserts, but not on updates of well-populated rows. Core SQL or PL/PGSQL statements won't do the job. Regards, Andreas