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

From: Frank Joerdens <frank(at)joerdens(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rule trouble (looks to me exactly like the example)
Date: 2002-04-07 14:15:19
Message-ID: 20020407161519.A9927@superfly.archi-me-des.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Apr 05, 2002 at 10:42:18AM -0500, Tom Lane wrote:
> Frank Joerdens <frank(at)joerdens(dot)de> writes:
> >> 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.
>
> I was speaking of the WHERE new.id > 0 part.

Oh yes, that's silly indeed. I just put it there to make the query look like
the example.

> However, given that you
> want to affect only the newly-inserted row, ISTM you'd be a lot better
> off with a trigger instead of a rule.

I'll give that a try!

Thanks, Frank

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ian Cass 2002-04-08 12:35:28 JOINS and non use of indexes
Previous Message Tom Lane 2002-04-06 15:45:35 Re: intersect performance (PG 7.1.3 vs 7.2)