pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hano de la Rouviere <hano@linutech.co.za>
To: Graham Vickrage <graham@digitalplanit.com>
To: Postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: trigger on table
Date: Thu, 14 Feb 2002 14:27:19 +0200
Message-ID: <000a01c1b552$f228a420$05faa8c0@edios> (raw)
References: <NDBBJABDILOPAOOMFJHOIEMHDDAA.graham@digitalplanit.com>

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" <graham@digitalplanit.com>
To: "Postgres SQL" <pgsql-sql@postgresql.org>
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
>




view thread (5+ messages)  latest in thread

Message-ID: <000a01c1b552$f228a420$05faa8c0@edios>
Permalink:  ../000a01c1b552$f228a420$05faa8c0@edios/
Also on:    postgresql.org/message-id/000a01c1b552$f228a420$05faa8c0@edios

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hano@linutech.co.za, graham@digitalplanit.com
  Subject: Re: trigger on table
  In-Reply-To: <000a01c1b552$f228a420$05faa8c0@edios>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox