Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 605ED6333B5 for ; Fri, 12 Jun 2009 21:22:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 78984-06 for ; Fri, 12 Jun 2009 21:22:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mail.postgresql.org (Postfix) with ESMTP id A4630633701 for ; Fri, 12 Jun 2009 21:22:44 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MFH14-00014a-UZ for pgsql-sql@postgresql.org; Sat, 13 Jun 2009 00:22:39 +0000 Received: from s01060015e975d7fb.wp.shawcable.net ([24.77.73.195]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Jun 2009 00:22:38 +0000 Received: from spluque by s01060015e975d7fb.wp.shawcable.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 13 Jun 2009 00:22:38 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Seb Subject: Re: updateable/insertable view having left joined tables Date: Fri, 12 Jun 2009 19:22:27 -0500 Organization: Church of Emacs Lines: 17 Message-ID: <87iqj1t22k.fsf@kolob.sebmags.homelinux.org> References: <87prd9t9te.fsf@kolob.sebmags.homelinux.org> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: s01060015e975d7fb.wp.shawcable.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) Cancel-Lock: sha1:Svl2Mp/t+P6dCzxFtH5+NfR5pA0= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200906/67 X-Sequence-Number: 32672 The following seems to work, but I don't feel confident this is really the correct code: CREATE RULE shoe_upd AS ON UPDATE TO shoe DO INSTEAD ( UPDATE shoes SET sh_name = NEW.sh_name, sh_avail = NEW.sh_avail WHERE shoes.sh_id = NEW.sh_id; INSERT INTO shoelaces (sh_id, sl_name) SELECT New.sh_id, New.sl_name WHERE New.sl_name IS NOT NULL;); I could find out doing a number of tests, but it would be good to understand what is going on. -- Seb