How can I use UNION in VIEW/RULE? - Mailing list pgsql-hackers

From Werachart Jantarataeme
Subject How can I use UNION in VIEW/RULE?
Date
Msg-id Pine.GSO.3.93.990510155037.19591B-100000@pegasus1
Whole thread Raw
List pgsql-hackers
I have 2 table say c1,c2 (same attributes) and then I would like to 

CREATE VIEW c AS  SELECT * FROM c1  UNION   SELECT * FROM c2;

But the system not accept. (not implement)
Then I change to use 
CRATE TABLE c (<** attributes are same as c1,c2 **>)
CREATE RULE r1 AS ON SELECT to c  DO INSTEAD  SELECT * FROM c2  UNION  SELECT * FROM c1;

Tbe system accept this rule but when I process 'SELECT * FROM c1;', the
result is not sastified; only tuples on c2 are display.

Is there other way to get result like above. One I've thought in mind is:-
CREATE RULE r1 AS ON SELECT to c DO INSTEAD SELECT funct_UNION(c1,c2);
But I have no idea how to do kinds of the function that return set of
tuple

WChart.




pgsql-hackers by date:

Previous
From: Werachart Jantarataeme
Date:
Subject: Can a function return tuples
Next
From: ZEUGSWETTER Andreas IZ5
Date:
Subject: Re: [HACKERS] Re: Number of parameters in a sql function