From: | "Chris Griffin" <cgriffin(at)websales(dot)com> |
---|---|
To: | pgsql-sql(at)hub(dot)org |
Subject: | Creating rules |
Date: | 1999-09-24 15:39:13 |
Message-ID: | 199909241539.IAA06178@websales.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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...
From | Date | Subject | |
---|---|---|---|
Next Message | Albert REINER | 1999-09-24 20:47:49 | Re: [SQL] comparing 2 tables. . . |
Previous Message | Stuart Rison | 1999-09-24 14:32:51 | RE: [SQL] comparing 2 tables. . . |