X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4BE2BDAC6B for ; Tue, 25 Oct 2005 09:07:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04797-02 for ; Tue, 25 Oct 2005 12:07:37 +0000 (GMT) Received: from halfgaar.kicks-ass.net (cc503261-a.eelde1.dr.home.nl [217.121.237.58]) by svr1.postgresql.org (Postfix) with ESMTP id 1455FDAC33 for ; Tue, 25 Oct 2005 09:07:38 -0300 (ADT) Received: from localhost ([127.0.0.1]) by halfgaar.kicks-ass.net with esmtp (Exim 4.50) id 1EUNaf-0004Vv-5c; Tue, 25 Oct 2005 14:07:41 +0200 Message-ID: <435E200C.5090405@gmail.com> Date: Tue, 25 Oct 2005 14:07:40 +0200 From: Wiebe Cazemier User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050729) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sarah Asmaels Cc: pgsql-sql@postgresql.org Subject: Re: writable joined view References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.394 required=5 tests=[AWL=-0.448, FORGED_RCVD_HELO=0.05, RCVD_IN_NJABL_DUL=1.655, RCVD_IN_SORBS_DUL=0.137] X-Spam-Level: * X-Archive-Number: 200510/283 X-Sequence-Number: 23136 Sarah Asmaels wrote: > Hi! > > I have one table referencing an object in another table through an ID, > and a view joining those tables on the ID. I want to create rules to > rewrite updates/deletes/inserts on the joined view to act on the real > tables. Can you give me some pointers? The documentation has only > examples for views depending on single tables. > > Thank you, > > Sarah Is there any difference in multi or single table view? When you create a rule, you have access to NEW and/or OLD, which will contain all the fields your view has. You can then do something like this: CREATE RULE insert_rule AS ON INSERT TO your_view DO INSTEAD ( INSERT INTO table1 (name) VALUES (NEW.name); INSERT INTO table2 (favorite_color) VALUES (NEW.favorite_color); ); Or is there something I'm not understanding about your request, or perhaps rules in general?