Re: rules on INSERT can't UPDATE new instance?
Louis-David Mitterrand <cunctator@apartia.ch>
From: Louis-David Mitterrand <cunctator@apartia.ch>
To: pgsql-general@hub.org
Date: 2000-05-20T13:44:17Z
Lists: 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@apartia.org - http://www.apartia.fr MACINTOSH == Most Applications Crash If Not The Operatings System Hangs