Updates thru view

From: "Rajshekar" <riyer(at)kc(dot)rr(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Updates thru view
Date: 2002-02-12 01:44:27
Message-ID: %r_98.378530$8w3.96189889@typhoon.kc.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
Here's what I am trying to do.

create table shek_tab( id int , name char(20), age int DEFAULT 20 );
create view shek_view as select name, age from shek_tab where age = 24 ;
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 ;
create rule rule_update2 AS on update to shek_view do instead nothing;
insert into shek_tab values(1, 'Name1', 24);
insert into shek_tab values(2, 'Name2', 16);
insert into shek_tab values(3, 'Name3', 24);
insert into shek_tab values(4, 'Name4', 19);
insert into shek_tab values(5, 'Name5', 92);
insert into shek_tab values(6, 'Name6', 24);

When I execute an update on the view all the 6 rows are updated whereas only
3 satisfy the condition.

testdb=# update shek_view set age = 25 where age = 24;
UPDATE 6
^^^^^^^^^

Is there something wrong in the rules that I created?
Any help is appreciated.

Thanks
Rajshekar

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2002-02-12 01:47:21 Re: 7.2 PGDG RPMS and readline 4.0
Previous Message Mike Mascari 2002-02-12 01:26:58 Re: 7.2 PGDG RPMS and readline 4.0