Forum OpenACS Q&A: Porting triggers -- replace with ON UPDATE?

I'm new to Postgres, so forgive me if this is a really simple question. I've looked all around through the Postgres docs and through these Forums, as well as the two porting guides on this site.

If I'm porting a table from Oracle to Postgres that has a trigger on it that updates the date_modified column in the table, should I...

1) create a RULE in postgres

2) use the ON UPDATE (I saw an example of this, but couldn't find a really good example of how to do it.)

3) create a trigger.

create table foo ( 
  id primary key,
  date_modified date,
  other_data character(50)
);
I want the date_modified to change anytime anything else changes.
Collapse
Posted by Don Baccus on
We've always written triggers while porting ... keeps the code similar between the two versions.

Note in PG you write a function that does the trigger action, then define a trigger that calls the function.  Slightly awkward compared to having a code block attached to the trigger CREATE but it does work. Works well, actually.