Received: from superfly.archi-me-des.de (unknown [62.8.212.177]) by postgresql.org (Postfix) with ESMTP id E57A6475904 for ; Fri, 5 Apr 2002 05:04:05 -0500 (EST) Received: (from frank@localhost) by superfly.archi-me-des.de (8.9.3/8.9.3) id MAA01810 for pgsql-sql@postgresql.org; Fri, 5 Apr 2002 12:08:51 +0200 Date: Fri, 5 Apr 2002 12:08:51 +0200 From: Frank Joerdens To: pgsql-sql@postgresql.org Subject: Re: Rule trouble (looks to me exactly like the example) Message-ID: <20020405120851.D30469@superfly.archi-me-des.de> References: <20020404191719.C30469@superfly.archi-me-des.de> <25306.1017948553@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.1.2i In-Reply-To: <25306.1017948553@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Thu, Apr 04, 2002 at 02:29:13PM -0500 X-Subliminal-Message: Use Linux! Use Linux! X-Archive-Number: 200204/64 X-Sequence-Number: 7329 On Thu, Apr 04, 2002 at 02:29:13PM -0500, Tom Lane wrote: > Frank Joerdens writes: > > And here's the rule (it doesn't do anything real or interesting, I just > > simplified it to the point where it looked like the example): > > > CREATE RULE insert_level AS > > ON INSERT TO tree > > WHERE new.id > 0 DO > > UPDATE tree SET leveling = 1 > > WHERE tree.oid = new.oid; > > What's happening is that "new.id" is effectively still NULL at the point > where the rule is processed, so the rule WHERE condition fails. I'm not > sure why you're bothering with that WHERE condition anyway ... Without the WHERE condition, all rows are affected by the update, and not just the newly inserted one. Regards, Frank