On Sat, 27 Sep 2003, Sven Schwyn wrote:
> Hi
>
> Many people are asking how to automatically update columns containing a
> modification date on updates. I'm wondering if the only solutions in
> the current pgsql really are...
>
> - adding "modification=NOW()" to every update query "manually"
> - defining a trigger called on updates
>
> While addings things "manually" is quite clumsy, a trigger actually
> causes a second update thus slowing down the Db.
>
I suspect you're misunderstanding something about triggers, an on update
trigger setting a such a field to the current timestamp shouldn't be causing a
second update. You're actually doing an update statement within the trigger I
presume? That's not the way, just set NEW.modified to the value you want,
eg. the current timestamp.
> As far as I know, rules don't help due to circular conditions (an
> update causes an update causes an update...) and functions stil require
> to add stuff to each and every update. But I could be wrong. Please -
> anyone - enlighten me, us and the world :-)
Does an update within a rule get rewritten by the rule system if it's on the
same table as the rule?
Nigel Andrews