Received: from zukerman-1.dsl.speakeasy.net (zukerman-1.dsl.speakeasy.net [216.254.75.142]) by hub.org (8.10.1/8.10.1) with ESMTP id e76NWvG97015 for ; Sun, 6 Aug 2000 19:32:57 -0400 (EDT) Received: from (matt.w80.math-hat.com) [216.254.75.141] by zukerman-1.dsl.speakeasy.net with esmtp (Exim 3.12 #1 (Debian)) id 13LZtA-0007zA-00; Sun, 06 Aug 2000 19:31:28 -0400 Received: from zukerman by matt.w80.math-hat.com with local (Exim 3.12 #1 (Debian)) id 13LZub-0004XQ-00 for ; Sun, 06 Aug 2000 19:32:57 -0400 To: pgsql-sql@postgresql.org Subject: Rules, Select, Union From: Itai Zukerman Date: 06 Aug 2000 19:32:57 -0400 Message-ID: <87d7jmrmmu.fsf@matt.w80.math-hat.com> Lines: 33 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200008/46 I'm doing this: CREATE TABLE data ( val int4 ); CREATE TABLE pos ( ) INHERITS ( data ); CREATE TABLE neg ( ) INHERITS ( data ); CREATE RULE data_to_pos AS ON INSERT TO data WHERE NEW.val > 0 DO INSTEAD INSERT INTO pos ( val ) VALUES ( NEW.val ); CREATE RULE data_to_neg AS ON INSERT TO data WHERE NEW.val < 0 DO INSTEAD INSERT INTO neg ( val ) VALUES ( NEW.val ); So far, I think, so good. (Though, sometimes it looks like the second rule is never triggered even though val < 0. The real application that this simple example comes from has a bunch of triggers, though, so it could be some weird interaction...) Now I want to do: CREATE RULE data_val AS ON SELECT TO data DO INSTEAD SELECT * FROM pos UNION SELECT * FROM neg; Can this be done? I'm not having much success... This is 7.0.2... -itai