From: Itai Zukerman <zukerman@math-hat.com>
To: pgsql-sql@postgresql.org
Subject: Rules, Select, Union
Date: 06 Aug 2000 19:32:57 -0400
Message-ID: <87d7jmrmmu.fsf@matt.w80.math-hat.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: zukerman@math-hat.com
Subject: Re: Rules, Select, Union
In-Reply-To: <87d7jmrmmu.fsf@matt.w80.math-hat.com>
References: <87d7jmrmmu.fsf@matt.w80.math-hat.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox