Re: Modification Dates

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Sven Schwyn <zeug(at)bluewin(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Modification Dates
Date: 2003-09-29 00:09:52
Message-ID: Pine.LNX.4.21.0309290103420.31021-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-09-29 00:12:51 Re: Hesitate to write this: can't get at postgres.org
Previous Message Bruce Momjian 2003-09-28 19:40:03 Re: ADD FOREIGN KEY (was Re: [GENERAL] 7.4Beta)