Re: Updates thru view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rajshekar" <riyer(at)kc(dot)rr(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Updates thru view
Date: 2002-02-18 21:15:20
Message-ID: 13795.1014066920@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Rajshekar" <riyer(at)kc(dot)rr(dot)com> writes:
> create rule rule_update AS on update to shek_view
> where old.age = 24
> do update shek_tab set age = new.age where old.age = 24 ;

Try

create rule rule_update AS on update to shek_view
where old.age = 24
do update shek_tab set age = new.age where age = old.age;

Your form of the rule reduces to
update shek_tab set age = new.age where true;
which unsurprisingly updates all rows of the table.

I do not exactly see the point of the conditional rule, either.
Why not just

create rule rule_update AS on update to shek_view
do update shek_tab set age = new.age where age = old.age;

The view already restricts visibility of rows, you do not need to
do it twice more in the rules.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eric Peters 2002-02-18 21:34:31 is it possible to return multiple rows in a PL/PGSQL function?
Previous Message Command Prompt, Inc. 2002-02-18 21:14:48 PgManage update