Received: from sysadmin.chi.wdr.com (sysadmin.chi.ubswarburg.com [146.180.1.66]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f147xYx69591 for ; Sun, 4 Feb 2001 02:59:35 -0500 (EST) (envelope-from devin@sysadmin.chi.wdr.com) Received: from devin by sysadmin.chi.wdr.com with local (Exim 3.12 #2) id 14PK4d-0001gZ-00; Sun, 04 Feb 2001 01:59:03 -0600 Date: Sun, 4 Feb 2001 01:59:03 -0600 (CST) From: Tod McQuillin X-X-Sender: To: Tom Lane cc: Subject: Re: Bug with rules in 7.0.3? In-Reply-To: <2363.981224317@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200102/26 X-Sequence-Number: 1194 On Sat, 3 Feb 2001, Tom Lane wrote: > I get > > regression=# SELECT * FROM orders; > order_id | menu_id | price > ----------+---------+------- > 1 | 2 | -1 > (1 row) > > which is the correct result given that rules are executed before the > original query. (Which is why you need a trigger for this...) OK. I think that Bruce's book is inaccurate then. In section D.19 (p. 299), also reproduced on the web at http://www.postgresql.org/docs/aw_pgsql_book/node490.html, this example is given: All new employees must make 5,000 or less: CREATE RULE example_5 AS ON INSERT TO emp WHERE new.salary > 5000 DO UPDATE emp SET salary = 5000 WHERE emp.oid = new.oid; -- Tod McQuillin