[repost] trigger update time
От | Rory Campbell-Lange |
---|---|
Тема | [repost] trigger update time |
Дата | |
Msg-id | 20020619083634.GB7752@campbell-lange.net обсуждение исходный текст |
Ответы |
Re: [repost] trigger update time
Re: [repost] trigger update time |
Список | 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@campbell-lange.net> <www.campbell-lange.net>
В списке pgsql-novice по дате отправления: