Performing INSERT from a Trigger fired function - Mailing list pgsql-general

From Darrell Skogman
Subject Performing INSERT from a Trigger fired function
Date
Msg-id 20021004115419.18344.qmail@email.com
Whole thread Raw
Responses Re: Performing INSERT from a Trigger fired function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I want to be able to capture changes to a db with the use of triggers. I have created a simple db to test the methods
todo this. When I change the age in this example, I get the error - "cashe lookup failed". I drop the trigger and the
functionbefore I make a change to the function and create the function and then the trigger to test changes. I always
getthis error. The scripts I use are attached. Thanks in advance the any ad all input... I love this stuff!  

CREATE TABLE "consumer" (
"name" varchar(35),
"age" int4
);
----------
CREATE TABLE "changes" (
"name" varchar(50),
"oldage" int4
);
----------------------------
CREATE FUNCTION "save_change"() RETURNS "opaque" AS
'BEGIN
INSERT INTO changes( name, oldage )
VALUES( new.name, old.age );
RETURN new;
END;
' LANGUAGE 'plpgsql';
-------------------------------------------------
CREATE TRIGGER "xs" AFTER UPDATE ON "consumer" FOR EACH ROW EXECUTE PROCEDURE save_change()
--------------------------------------------------
DROP Trigger "xs" on "consumer" ;
------------------------------------------------
DROP FUNCTION "save_change"();



--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


"Free price comparison tool gives you the best prices and cash back!"
http://www.bestbuyfinder.com/download.htm


pgsql-general by date:

Previous
From: andreas@sparcy.net (Andreas Forsgren)
Date:
Subject: Odd sum() problem in 7.2.2
Next
From: "luc neulens"
Date:
Subject: transactions