Re: Touch row ? - Mailing list pgsql-general

From Chris Travers
Subject Re: Touch row ?
Date
Msg-id 016c01c3e23c$069f6390$97285e3d@winxp
Whole thread Raw
In response to Re: Upcoming events  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Touch row ?
List pgsql-general
I too have also noticed that the rule is a really cool way to write
lightweight triggers.  They are also simpler to use, and often perform
better.  You can also make them conditional which you cannot do with
triggers at the moment.

I think this timestamp concept is a perfect example of where a rule is
better.  It doesn't have to be done on a view either.
For example:
CREATE TABLE  mytable (
    my_id SERIAL PRIMARY KEY,
    last_updated TIMESTAMP);
CREATE RULE touch_row AS ON UPDATE TO mytable DO
(UPDATE mytable SET last_updated = NOW() WHERE my_id = NEW.my_id);

I assume that if you have extremely complex business logic in your triggers,
triggers might be better because they are executed in a defined order.  But
for something like this, I fail to see how it makes things easier rather
than harder.

Best Wishes,
Chris Travers


pgsql-general by date:

Previous
From: Dan Langille
Date:
Subject: Re: [pgsql-advocacy] LIVE Coverage of LinuxWorld Conference & Expo
Next
From: Eric B.Ridge
Date:
Subject: Re: Touch row ?