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

Re: Creating Functions & Triggers

From: "V i s h a l Kashyap (at) [Sai Hertz And Control Systems]" <sank89(at)sancharnet(dot)in>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Creating Functions & Triggers
Date: 2004-03-21 03:30:25
Message-ID: 405D0C51.3040507@sancharnet.in (view raw or flat)
Thread:
Lists: pgsql-novice
Dear Kevin ,

> 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 FUNCTION email_mod_date() RETURNS OPAQUE AS '
 DECLARE
  BEGIN
        UPDATE email SET  m_date = current_date, m_by_user = current_user
        WHERE id = NEW.id;

  RETURN NEW;
  END;
'LANGUAGE 'plpgsql';

This must do the job.
But why you need a trigger for all this.

Just use a default value for the respective column's .


-- 
Best Regards,
Vishal Kashyap
Director / Lead Developer,
Sai Hertz And Control Systems Pvt Ltd,
http://saihertz.rediffblogs.com
Jabber IM: vishalkashyap(at)jabber(dot)org
ICQ :      264360076
Yahoo  IM: mailforvishal(at)yahoo(dot)com
-----------------------------------------------
You yourself, as much as anybody in the entire
universe, deserve your love and affection.
- Buddha
---------------
pgsql=# select marital_status from vishals_life;

marital_status
------------------
Single not looking

1 Row(s) affected

                    ___
                   //\\\
                  ( 0_0 )
----------------o0o-----o0o---------------------


In response to

pgsql-novice by date

Next:From: V i s h a l Kashyap @ [Sai Hertz And Control Systems]Date: 2004-03-21 04:08:38
Subject: Re: Creating Functions & Triggers
Previous:From: Robert MorganDate: 2004-03-21 01:01:03
Subject: Re: connect from network PC

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