How to create a trigger

From: "Laurent Duperval" <lduperval(at)microcelli5(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to create a trigger
Date: 2001-05-10 20:46:18
Message-ID: 9deun0$25v8$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I know nothing about triggers so I need a little hand-holding here. I'm
taking an Oracle script and converting it to pgsql. One of the things
that the Oracle database supports is a trigger on dates. So there are two
fields in the table, CREATION_DATE and UPDATE_DATE.

In the CREAT TABLE statement, I can set both dates using DEFAULT (once I
figure out how to get today's date in). But hoiw would I write a trigger
that changes the update_date to use the current time? Basically, I guess
it would be

create trigger date_update before update on mytable
for each statement execut procedure [procedure that inserts a date
for me in the update_date column]

So what would I be doing for the portion in brackets?

Thanks,

L

--
Laurent Duperval <mailto:lduperval(at)microcelli5(dot)com>

Les plus vigoureux coups de main au destin n'aboutissent pas toujours dans la
vie, aux démarrages qu'on attendait.
-Alambic Talon

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zak McGregor 2001-05-10 20:46:27 Re: formatting a date
Previous Message Tom Lane 2001-05-10 20:45:54 Re: COPY locking