Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UDxvA-0008D0-BE for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2013 14:05:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UDxv9-0007xi-H5 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2013 14:05:15 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UDvcn-00017t-GR for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 11:38:09 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UDvci-0005FH-AB for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 11:38:08 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UDvch-0000R9-Bt for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 11:38:04 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UDvch-0004Qr-4C for pgsql-bugs@postgresql.org; Fri, 08 Mar 2013 11:38:03 +0000 Date: Fri, 08 Mar 2013 11:38:03 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7924: Trigger update function don't take correct values To: pgsql-bugs@postgresql.org From: mv.gonzalez@cir.es X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7924 Logged by: Maria Email address: mv.gonzalez@cir.es PostgreSQL version: Unsupported/Unknown Operating system: RedHat Description:=20=20=20=20=20=20=20=20 Hi! I have a trigger that when you update a value on a table, makes an insert into another table. The trigger looks like the following: BEGIN set datestyle to 'sql'; set datestyle to 'european'; IF (TG_OP =3D 'UPDATE' and (OLD.situation!=3DNEW.situation)) THEN INSERT INTO table_B VALUES (OLD.id,NEW.situation,NOW()); END IF; RETURN NULL; END; For exemple, If I do the next querys: --> update table_A set situation=3D'Started' where id=3D'23'; On table_A appears: id | situation=20 --------+----------- 23 | Started On table_B appears: id | situation | when --------+-----------+--------------------- 23 | Started | 2013-03-08 12:33:35 --> update table_A set situation=3D'Waiting' where id=3D'23'; On table_A appears: id | situation=20 --------+----------- 23 | Waiting On table_B appears: id | situation | when --------+-----------+--------------------- 23 | Started | 2013-03-08 12:33:35 23 | Started | 2013-03-08 12:33:37 I don't understand why after the second update, the insert done on table_B is incorrect, and has the same values that the first one.=20 I've been looking for some kind of explanation like cache or something, but I couldn't find anything. Thanks in advance. Maria --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs