X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2E752D1B4B2 for ; Fri, 16 Apr 2004 15:12:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23855-07 for ; Fri, 16 Apr 2004 15:12:12 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id D9321D1D067 for ; Fri, 16 Apr 2004 15:12:13 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i3GICDSx059619 for ; Fri, 16 Apr 2004 18:12:13 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i3GHhUR1053967 for pgsql-sql@postgresql.org; Fri, 16 Apr 2004 17:43:30 GMT From: cpng@sophos.com (Cornelius Grotjahn) X-Newsgroups: comp.databases.postgresql.sql Subject: What is the best way of writing update rule on view with joined tables? Date: 16 Apr 2004 10:43:31 -0700 Organization: http://groups.google.com Lines: 29 Message-ID: <195fde65.0404160943.722481e3@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/169 X-Sequence-Number: 17544 Please, how can I rewrite the rule below so that it works as intended for this update: update v set ad=0, bd=0 where ad=1; As it is now, this will change ad but not bd, presumably because when the rule's first action has updated ad, the "where ad=1" returns 0 rows for the second action. I want this because that is the way MS Access puts data into updates' where clauses and I want updateable forms on joined tables. create table a (k integer primary key, ad integer); create table b (k integer primary key, bd integer); create view v as select a.k, ad, bd from a join b on a.k=b.k; create rule r as on update to v do instead ( update a set ad=new.ad where k=old.k; update b set bd=new.bd where k=old.k; ); insert into a values(1,1); insert into a values(2,2); insert into b values(1,1); insert into b values(2,2); Thank you -- Cornelius