Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id DADA2632796 for ; Wed, 22 Jul 2009 08:42:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 33900-02 for ; Wed, 22 Jul 2009 08:42:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from tomts16-srv.bellnexxia.net (tomts16.bellnexxia.net [209.226.175.4]) by mail.postgresql.org (Postfix) with ESMTP id 09ECF63277F for ; Wed, 22 Jul 2009 08:42:11 -0300 (ADT) Received: from toip5.srvr.bell.ca ([209.226.175.88]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20090722114210.RLCZ13336.tomts16-srv.bellnexxia.net@toip5.srvr.bell.ca> for ; Wed, 22 Jul 2009 07:42:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuAEABeVZkpA51xt/2dsb2JhbACBUc8nhA4F Received: from bas4-london14-1088904301.dsl.bell.ca (HELO t60p.bax.ca) ([64.231.92.109]) by toip5.srvr.bell.ca with ESMTP; 22 Jul 2009 07:47:10 -0400 Message-ID: <4A66FB11.1000302@sympatico.ca> Date: Wed, 22 Jul 2009 07:42:09 -0400 From: Frank Bax User-Agent: Thunderbird 2.0.0.19 (X11/20090301) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: how to tell if column set on update References: <137458.25689.qm@web54304.mail.re2.yahoo.com> In-Reply-To: <137458.25689.qm@web54304.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.29 tagged_above=-10 required=5 tests=AWL=0.290 X-Spam-Level: X-Archive-Number: 200907/97 X-Sequence-Number: 32838 chester c young wrote: >> Le 20/07/09 15:19, chester c young a écrit : >>> within a trigger need to know if the UPDATE statement >> set a column. the column might be set to the old value >> or a different value. >>> (want to make sure the app is sending all necessary >> values) >>> thanks >>> >> If the column to test is known -- e.g. column MyCol --, >> NEW.MyCol and >> OLD.MyCol -- respectively value of MyCol after UPDATE and >> value of MyCol >> before UPDATE -- can be compared. > > for example, > create table t1( c1 int, c2 int ); > insert into t1 values( 1, 2 ); > > 1) update t1 set c1=4 where c1=1; > 2) update t1 set c1=4, c2=2 where c1=1; > > each update results in the same row, but in the second update c2 was actually set. > a trigger on the update - how do we know if c2 has been actually set or not? You cannot do that. You can only detect that a value has changed.