pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nicolas KOWALSKI <Nicolas.Kowalski@imag.fr>
To: pgsql-admin@postgresql.org
Subject: update in rule
Date: Wed, 17 Oct 2001 19:24:42 +0200
Message-ID: <vqobsj6qiw5.fsf@brevent.imag.fr> (raw)


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.




view thread (8+ messages)  latest in thread

Message-ID: <vqobsj6qiw5.fsf@brevent.imag.fr>
Permalink:  ../vqobsj6qiw5.fsf@brevent.imag.fr/
Also on:    postgresql.org/message-id/vqobsj6qiw5.fsf@brevent.imag.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Nicolas.Kowalski@imag.fr, pgsql-admin@postgresql.org
  Subject: Re: update in rule
  In-Reply-To: <vqobsj6qiw5.fsf@brevent.imag.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox