Skip site navigation (1) Skip section navigation (2)

Creating Functions & Triggers

From: Kevin Lohka <klohka(at)aboutfacedata(dot)ab(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Creating Functions & Triggers
Date: 2004-03-20 22:33:19
Message-ID: 96880EBE-7ABE-11D8-A9E9-000A95728606@aboutfacedata.ab.ca (view raw or flat)
Thread:
Lists: pgsql-novice
Hello everyone, I'm new to creating functions & triggers on postgresql 
and am having trouble creating a trigger to update a record with the 
modification date and the current user.

My code is below, but doesn't work.  It hangs psql when I attempt to 
modify the record.  The function and trigger are created successfully.

CREATE FUNCTION email_mod_date() RETURNS OPAQUE AS '
   BEGIN
         UPDATE email SET  m_date = current_date, m_by_user = 
current_user
         WHERE id = NEW.id;

   RETURN NULL;
   END;
'LANGUAGE 'plpgsql';



CREATE TRIGGER email_mod_date
AFTER UPDATE
ON email
FOR EACH ROW
EXECUTE PROCEDURE email_mod_date();

Thanks for any help.

Kevin Lohka


Responses

pgsql-novice by date

Next:From: Robert MorganDate: 2004-03-21 01:01:03
Subject: Re: connect from network PC
Previous:From: Jay DavisDate: 2004-03-20 21:32:08
Subject: How do you do a negative join?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group