Received: from mars.linutech.co.za (bnb53-01-186.nt.saix.net [155.239.181.186]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1ECWhE46946 for ; Thu, 14 Feb 2002 07:32:50 -0500 (EST) (envelope-from hano@linutech.co.za) Received: from edios (edios.linutech.co.za [192.168.250.5]) by mars.linutech.co.za (8.11.0/8.11.0) with SMTP id g1ECaRV04504; Thu, 14 Feb 2002 14:36:27 +0200 Message-ID: <000a01c1b552$f228a420$05faa8c0@edios> From: "Hano de la Rouviere" To: "Graham Vickrage" , "Postgres SQL" References: Subject: Re: trigger on table Date: Thu, 14 Feb 2002 14:27:19 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200202/265 X-Sequence-Number: 6688 Try CREATE FUNCTION set_item_last_updated () RETURNS OPAQUE AS ' BEGIN NEW.last_updated = now(); RETURN NEW; END;' LANGUAGE 'plpgsql'; CREATE TRIGGER item_last_updated BEFORE UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE set_item_last_updated(); Make sure its BEFORE... Hope this helps http://www.pgexplorer.com GUI Tool for Postgres ----- Original Message ----- From: "Graham Vickrage" To: "Postgres SQL" Sent: Thursday, February 14, 2002 2:17 PM Subject: [SQL] trigger on table > I am trying to create a trigger on a table that simply sets the last_updated > field when any updates are made to that table. > > I have tried the following: - > > CREATE FUNCTION set_item_last_updated () RETURNS OPAQUE AS ' > BEGIN > UPDATE item SET last_updated = now(); > RETURN OLD; > END;' LANGUAGE 'plpgsql'; > > CREATE TRIGGER item_last_updated AFTER UPDATE ON item > FOR EACH ROW EXECUTE PROCEDURE set_item_last_updated(); > > When I try to execute this it hangs and postmaster eventually runs out of > memory. > > Is there a way to do it just using sql not plpsql? > Why is it hanging? > > Thank in advance. > > Graham > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >