From: mv.gonzalez@cir.es
To: pgsql-bugs@postgresql.org
Subject: BUG #7924: Trigger update function don't take correct values
Date: Fri, 08 Mar 2013 11:38:03 +0000
Message-ID: <E1UDvch-0004Qr-4C@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
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:
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 = 'UPDATE' and (OLD.situation!=NEW.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='Started' where id='23';
On table_A appears:
id | situation
--------+-----------
23 | Started
On table_B appears:
id | situation | when
--------+-----------+---------------------
23 | Started | 2013-03-08 12:33:35
--> update table_A set situation='Waiting' where id='23';
On table_A appears:
id | situation
--------+-----------
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.
I've been looking for some kind of explanation like cache or something, but
I couldn't find anything.
Thanks in advance.
Maria
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: mv.gonzalez@cir.es
Subject: Re: BUG #7924: Trigger update function don't take correct values
In-Reply-To: <E1UDvch-0004Qr-4C@wrigleys.postgresql.org>
References: <E1UDvch-0004Qr-4C@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox