Re: rules on INSERT can't UPDATE new instance? - Mailing list pgsql-general

From Louis-David Mitterrand
Subject Re: rules on INSERT can't UPDATE new instance?
Date
Msg-id 20000520154417.A5252@styx
Whole thread Raw
In response to Re: rules on INSERT can't UPDATE new instance?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: rules on INSERT can't UPDATE new instance?
List pgsql-general
On Sat, May 20, 2000 at 07:35:38AM -0400, Bruce Momjian wrote:
> >  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.

But this doesn't work in PG 7.0:

auction=> create table test (price float);
CREATE
auction=> create rule price_control AS ON INSERT TO test WHERE new.price > 100 DO UPDATE test SET price = 100 where
test.oid= new.oid; 
CREATE 27913 1
auction=> INSERT INTO test VALUES (101);
INSERT 27914 1
auction=> SELECT test.*;
 price
-------
   101
(1 row)


--
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.fr

MACINTOSH == Most Applications Crash If Not The Operatings System Hangs

pgsql-general by date:

Previous
From: Ned Lilly
Date:
Subject: RPM troubleshoot
Next
From: Louis-David Mitterrand
Date:
Subject: access to mailing list archives broken