From: Chris Griffin <cgriffin@websales.com>
To: pgsql-sql@hub.org
Subject: Creating rules
Date: Fri, 24 Sep 1999 08:39:13 -0700
Message-ID: <199909241539.IAA06178@websales.com> (raw)
I am trying to create a rule that will set the 'date_created' field of a
newly inserted record to 'now'. When I try to write something like the
example in the book...
create rule example_5 as
on insert to EMP where new.salary > 5000
do update newset salary = 5000
as
create rule test_rule as
on insert to candidate
do update newset date_created = current_date;
that gives me an error of:
ERROR: parser: parse error at or near "date_created"
if I change it to this:
create rule test_rule as
on insert to candidate
do update candidate set date_created=current_date;
it creates the rule but when I do an insert it looks like it is updating
all the records except the one I'm inserting. So what's the best way to do
this. I have about 6 tables I would like to do this for. Thanks...
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: cgriffin@websales.com, pgsql-sql@hub.org
Subject: Re: Creating rules
In-Reply-To: <199909241539.IAA06178@websales.com>
References: <199909241539.IAA06178@websales.com>
* 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