X-Original-To: pgsql-sql@postgresql.org Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by postgresql.org (Postfix) with ESMTP id 2F1EC47610A for ; Fri, 7 Mar 2003 05:30:39 -0500 (EST) Received: from p50818a59.dip0.t-ipconnect.de ([80.129.138.89] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18rF7e-0005wz-00 for pgsql-sql@postgresql.org; Fri, 07 Mar 2003 11:30:38 +0100 Message-ID: <3E6874CD.4090501@web.de> Date: Fri, 07 Mar 2003 11:30:37 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How to notice column changes in trigger Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/180 X-Sequence-Number: 12220 How can I detect whether a column was changed by an update command inside a trigger? create table test(a int, b int, c int, primary key(a)) b and c should be updated inside an update trigger if not modified by the statement itself 1) update test set a=0 -> trigger does its work 2) update test set a=0, b=1, c=2 -> trigger does nothing 3) update test set a=0, b=b, c=c -> trigger does nothing, but content of a and b dont change either although touched What I'm looking for is something like IF NOT COLUMN_TOUCHED(b) THEN ... For MSSQL, this would be coded as IF NOT UPDATE(b) .. IF OLD.b=NEW.b will not work, case 3) will falsely execute the trigger code. Any hints? Andreas