I hope I'm not transgressing the boundaries of list etiquette - I didn't
get a response to my first message so I've retitled it and resubmitted
it here.
I am trying to update a timestamp value in a related table using
functions and triggers, but failing miserably! I'd be grateful for some
help.
-----------------------------------------------------------------------
CREATE TABLE "a" (
"id" SERIAL,
"tstamp" timestamp
);
CREATE TABLE "b" (
"id" SERIAL,
"a_id" integer,
"tstamp" timestamp default current_timestamp.
);
CREATE FUNCTION "fnTU" () RETURNS opaque AS 'BEGIN
UPDATE a SET tstamp = new.tstamp;
WHERE new.a_id = id;
RETURN new;
END' LANGUAGE 'plpgsql';
CREATE TRIGGER "trgTU" AFTER INSERT ON "b" FOR EACH ROW EXECUTE
PROCEDURE "fnTU" ();
--
Rory Campbell-Lange
<rory@campbell-lange.net>
<www.campbell-lange.net>