From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
---|---|
To: | Postgresql Novice List <pgsql-novice(at)postgresql(dot)org> |
Subject: | [repost] trigger update time |
Date: | 2002-06-19 08:36:34 |
Message-ID: | 20020619083634.GB7752@campbell-lange.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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(at)campbell-lange(dot)net>
<www.campbell-lange.net>
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Johnson | 2002-06-19 10:35:38 | Re: Which indexes to drop |
Previous Message | John Taylor | 2002-06-19 08:24:56 | Re: Which indexes to drop |