Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 96D3663289C for ; Wed, 22 Jul 2009 22:43:16 -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 82834-07 for ; Wed, 22 Jul 2009 22:42:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.insa-lyon.fr (criges14.insa-lyon.fr [134.214.76.242]) by mail.postgresql.org (Postfix) with ESMTP id E9108632266 for ; Wed, 22 Jul 2009 22:43:05 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by smtp.insa-lyon.fr (Postfix) with ESMTP id 83062F129A; Thu, 23 Jul 2009 03:43:03 +0200 (CEST) X-Virus-Scanned: SMTP at INSA-LYON Received: from smtp.insa-lyon.fr ([127.0.0.1]) by localhost (criges14.insa-lyon.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xIZZlLf-IKrb; Thu, 23 Jul 2009 03:43:03 +0200 (CEST) Received: from [127.0.0.1] (liris.univ-lyon1.fr [134.214.142.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nhandrianar) by smtp.insa-lyon.fr (Postfix) with ESMTPSA id C723BF1284; Thu, 23 Jul 2009 03:43:02 +0200 (CEST) Message-ID: <4A67BFEC.7080906@free.fr> Date: Thu, 23 Jul 2009 03:42:04 +0200 From: nha Organization: Lyon, Rhone, France User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Chester C Young CC: PgSQL-sql Subject: Re: how to tell if column set on update References: <137458.25689.qm@web54304.mail.re2.yahoo.com> <4A66FB11.1000302@sympatico.ca> In-Reply-To: <4A66FB11.1000302@sympatico.ca> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/102 X-Sequence-Number: 32843 Hello, Le 22/07/09 13:42, Frank Bax a écrit : > 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. [...] >>>> >>> If the column to test is known -- e.g. column MyCol --, >>> NEW.MyCol and OLD.MyCol [...] 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. > There would be one way to detect a value change but it is more related to application management than to data manipulation. For the column c2, it could be assumed that a flag is set when (a row of) c2 is updated. Such a flag may be stored in a separate table (while it could also be added to table t1) that is updated with a trigger based on update on t1. Regards. -- nha / Lyon / France.