Thank you very much for the good product!
v7.3.2.
CREATE TABLE ta (c1 CHAR(1));
CREATE TABLE tb (c1 CHAR(1));
CREATE TABLE tc (c1 SMALLINT);
INSERT INTO ta VALUES('a');
INSERT INTO tb VALUES('b');
INSERT INTO tc VALUES(1);
SELECT c1 AS a,NULL AS b,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1,NULL FROM tb
UNION ALL
SELECT NULL,NULL,c1 FROM tc;
ERROR: UNION types 'text' and 'smallint' not matched
One union is fine:
SELECT c1 AS a,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1 FROM tc;
It's very difficult for me to cast types because this SQL is dynamically
generated by scripts rather than hard coded:
SELECT c1 AS a,NULL AS b,NULL AS c FROM ta
UNION ALL
SELECT NULL,c1,NULL::SMALLINT FROM tb
UNION ALL
SELECT NULL,NULL,c1 FROM tc;
Can postgreSQL be improved to be smarter with such UNION?
CN
--
http://www.fastmail.fm - A no graphics, no pop-ups email service