Re: Functions and Triggers - Mailing list pgsql-sql

From Jan Wieck
Subject Re: Functions and Triggers
Date
Msg-id 200103270959.EAA26759@jupiter.jw.home
Whole thread Raw
In response to Re: Functions and Triggers  (Cedar Cox <cedarc@visionforisrael.com>)
List pgsql-sql
Cedar Cox wrote:
>
> CREATE FUNCTION lastupdated() RETURNS opaque AS '
> begin
>   new.last_updated := CURRENT_TIMESTAMP;
>   return new;
> end;
> ' LANGUAGE 'plpgsql';
>
> CREATE TRIGGER trigname BEFORE INSERT OR UPDATE on tblname
>   FOR EACH ROW EXECUTE PROCEDURE lastupdated();
>
> Note: you could use now() instead of CURRENT_TIMESTAMP
>
> Note2: on a BEFORE trigger you must return new or old.  If you return null
> the statement will be aborted. (?)
   If  you  return NULL from a BEFORE trigger the action on that   particular row will be silently suppressed.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: all views in database broken at once
Next
From: "Sean Weissensee"
Date:
Subject: Upgrading from 6.2 to 7