From: Brook Milligan <brook@biology.nmsu.edu>
To: grant@intekom.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Adding a rule to update a last_changed field
Date: Fri, 22 Oct 1999 09:36:00 -0600 (MDT)
Message-ID: <199910221536.JAA04682@biology.nmsu.edu> (raw)
In-Reply-To: <221099295.28982@212.53.64.128>
References: <221099295.28982@212.53.64.128>
I'm trying to use a rule to maintain a last_changed field.
CREATE RULE rule1 AS
ON UPDATE TO thetable
DO UPDATE thetable SET last_changed = now()
WHERE id = new.id;
Try instead something like
CREATE RULE rule1 AS
ON UPDATE TO thetable
DO INSTEAD UPDATE thetable SET
last_changed = now(),
field1 = new.field1,
field2 = new.field2,
...
fieldn = new.fieldn
WHERE id = new.id;
That is, use an INSTEAD rule and replace each field explicitly.
Cheers,
Brook
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: brook@biology.nmsu.edu, grant@intekom.com
Subject: Re: [SQL] Adding a rule to update a last_changed field
In-Reply-To: <199910221536.JAA04682@biology.nmsu.edu>
References: <221099295.28982@212.53.64.128> <199910221536.JAA04682@biology.nmsu.edu>
* 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