Creating rules - Mailing list pgsql-sql

From Chris Griffin
Subject Creating rules
Date
Msg-id 199909241539.IAA06178@websales.com
Whole thread Raw
List pgsql-sql
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...


pgsql-sql by date:

Previous
From: Eric BASIER
Date:
Subject: Re: [SQL] comparing 2 tables. . .
Next
From: Jose Pedro Aragao - LEI
Date:
Subject: A question about triggers...