From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | ldm(at)apartia(dot)com |
Cc: | pgsql-general(at)hub(dot)org |
Subject: | Re: rules on INSERT can't UPDATE new instance? |
Date: | 2000-05-20 11:35:38 |
Message-ID: | 200005201135.HAA15697@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
>
> From the create_rule man page this example is offered:
>
> CREATE RULE example_5 AS
> ON INERT TO emp WHERE new.salary > 5000
> DO
> UPDATE NEWSET SET salary = 5000;
>
> But what is "NEWSET"? Is it a keyword?
It should be:
CREATE RULE example_5 AS
ON INERT TO emp WHERE new.salary > 5000
DO
UPDATE emp SET salary = 5000
WHERE emp.oid = new.oid;
Fixing now.
>
> My problem is that on an insert with an invalid amount I try to perform
> an update with a corrected amount, but the action part of the rule
> doesn't affect or "see" the newly inserted row (or so it seems).
>
> I tried: CREATE RULE ON INSERT TO bid WHERE new.price > limit
> DO UPDATE bid SET price = 0.1;
>
> and all price columns in the bid table would be set to 0.1 _except_ the
> newly inserted row.
>
> Am I missing something obvious?
No, buggy documentation. My book has a section on rules too, but you
should be fine now.
--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-05-20 11:37:59 | Re: Alias in WHERE clause |
Previous Message | Bruce Momjian | 2000-05-20 11:26:53 | Re: Auto-uppercase inserted column |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-05-20 12:24:44 | Re: Re: [HACKERS] Postgresql OO Patch |
Previous Message | Bruce Momjian | 2000-05-20 11:29:39 | Re: Raw devices (was Re: Berkeley DB license) |