Re: Rule trouble (looks to me exactly like the example)

From: Frank Joerdens <frank(at)joerdens(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rule trouble (looks to me exactly like the example)
Date: 2002-04-05 10:08:51
Message-ID: 20020405120851.D30469@superfly.archi-me-des.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Apr 04, 2002 at 02:29:13PM -0500, Tom Lane wrote:
> Frank Joerdens <frank(at)joerdens(dot)de> 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Magnus Enbom 2002-04-05 14:08:33 LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
Previous Message Tom Lane 2002-04-05 05:59:49 Re: Rule trouble (looks to me exactly like the example)