update in rule

From: Nicolas KOWALSKI <Nicolas(dot)Kowalski(at)imag(dot)fr>
To: pgsql-admin(at)postgresql(dot)org
Subject: update in rule
Date: 2001-10-17 17:24:42
Message-ID: vqobsj6qiw5.fsf@brevent.imag.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql


Hello.

We are running PostgreSQL 7.1.3 on Debian GNU/Linux.
We maintain for our intranet something like an addressbook :

<base>=# \d adresses
Table "adresses"
Attribute | Type | Modifier

--------------+------------------------+----------------------------------------
id | integer | default nextval('adresses_id_seq'::text)
<snip>
date_maj | date | default 'NOW'
Index: adresses_pkey

I would like to automatically update the `date_maj' field with the
current day date whenever an update on a row occurs.

So I created a rule like :

CREATE RULE adresses_date_maj
AS ON UPDATE TO adresses
DO UPDATE adresses SET date_maj = 'NOW' ;

But as says the documentation, this does not work (circular problem).

Does anyone known how to achieve such a behaviour ?

Thanks in advance,
Nicolas.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Stefan Huber 2001-10-17 17:25:23 Re: PG on Suse
Previous Message Fabio Serra 2001-10-17 15:52:44 PG on Suse

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-10-17 17:47:45 Re: index problem
Previous Message Haller Christoph 2001-10-17 17:17:44 Identifying obsolete values