From: | Itai Zukerman <zukerman(at)math-hat(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Rules, Select, Union |
Date: | 2000-08-06 23:32:57 |
Message-ID: | 87d7jmrmmu.fsf@matt.w80.math-hat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-08-07 01:09:20 | Re: Rules, Select, Union |
Previous Message | Tom Lane | 2000-08-06 05:45:21 | Re: Database in recovery mode |