How to create a trigger - Mailing list pgsql-general

From Laurent Duperval
Subject How to create a trigger
Date
Msg-id 9deun0$25v8$1@news.tht.net
Whole thread Raw
List 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@microcelli5.com>

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

pgsql-general by date:

Previous
From: "Torsten Krämer"
Date:
Subject: Archiver(tar): unable to find header for 52.dat
Next
From: Joel Burton
Date:
Subject: Re: Upcoming PostgreSQL seminars