Re: rules on INSERT can't UPDATE new instance?

From: Louis-David Mitterrand <cunctator(at)apartia(dot)ch>
To: pgsql-general(at)hub(dot)org
Subject: Re: rules on INSERT can't UPDATE new instance?
Date: 2000-05-20 13:44:17
Message-ID: 20000520154417.A5252@styx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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(at)apartia(dot)org - http://www.apartia.fr

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Louis-David Mitterrand 2000-05-20 13:47:10 access to mailing list archives broken
Previous Message Peter Eisentraut 2000-05-20 13:35:58 Re: Question about databases in alternate locations...

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Smith 2000-05-20 14:32:02 Re: Re: [HACKERS] Postgresql OO Patch
Previous Message Peter Eisentraut 2000-05-20 13:37:52 Thus spoke SQL3 (on OO)