Received: from laura.owlscreech.com (IDENT:root@[208.177.146.2]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA60000 for ; Wed, 31 May 2000 14:55:11 -0400 (EDT) (envelope-from brian@owlscreech.com) Received: from [208.177.146.11] (audrey.owlscreech.com [208.177.146.11]) by laura.owlscreech.com (8.9.3/8.8.7) with ESMTP id MAA05306 for ; Wed, 31 May 2000 12:55:10 -0600 User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Wed, 31 May 2000 12:55:09 -0600 Subject: creating rules on joined views From: Brian Powell To: Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Archive-Number: 200006/13 D'oh sorry for the subscribe message to the list... Greetings, I am new to PostGreSQL and the advanced capabilities that it offers. I would like to create a joined view that allows inserts and updates on two different tables (but, joined twice). Suppose you have: create table user { name varchar(40) not null, email varchar(80), address_id int4 not null, shipping_address_id int4 not null }; create table addresses { address_id int4 primary key default nextval('address_seq_id'), address varchar(80), city varchar(80) }; create view v_users as select u.name , u.email , a1.address , a1.city , a2.address as ship_address , a2.city as ship_city from user u , addresses a1 , addresses a2 where u.address_id = a1.address_id and u.shipping_address_id = a2.address_id Now, how would I create an insert rule on v_users because I have to insert two addresses first, retrieve their id's and insert those into the user table. Conversely, an update introduces its own challenges as well. If someone could show me these pieces, I have pretty much figured out everything else I need to do with the foreign keys, etc. It seems doable easily with pgpsql; however, I cannot use that for a rule, correct? Thanks, Brian