I want to convert the following table:
1 SET{10,11} SET{20,21}
2 SET{15} SET{30,31}
.
.
.
into this:
1 10 r
1 11 r
1 20 a
1 21 a
2 15 r
2 30 a
2 31 a
.
.
.
WITH ttt (sq, rejectedPinSet, acceptedPinSet) AS
(SELECT 1, SET{10,11}, SET{20,21} UNION ALL
SELECT 2, SET{15}, SET{30,31}
) SELECT * FROM ttt;
The following fails because ord+1 should come from "test" table but "test" table is not mentioned in the second UNION portion
WITH test(ord, PIN, ra) AS
((SELECT 1, *, 'r' FROM TABLE ((SELECT rejectedPinSet FROM ttt WHERE sq = 1)) AS rej(pin) UNION
SELECT 1, *, 'a' FROM TABLE ((SELECT acceptedPinSet FROM ttt WHERE sq = 1)) AS acp(pin)
) UNION
(SELECT ord+1, *, 'r' FROM TABLE ((SELECT rejectedPinSet FROM ttt WHERE sq = ord+1)) AS rej(pin) UNION
SELECT ord+1, *, 'a' FROM TABLE ((SELECT acceptedPinSet FROM ttt WHERE sq = ord+1)) AS acp(pin) )
) SELECT * FROM test
In the following construct I replaced ord+1 for
(SELECT ord+1 FROM test) but fails with error -26088:
WITH test(ord, PIN, ra) AS
((SELECT 1, pin, 'r' FROM TABLE ((SELECT rejectedPinSet FROM ttt WHERE sq = 1)) AS rej(pin) UNION
SELECT 1, pin, 'a' FROM TABLE ((SELECT acceptedPinSet FROM ttt WHERE sq = 1)) AS acp(pin))
UNION ALL
(SELECT (SELECT ord+1 FROM test), pin, 'r' FROM TABLE ((SELECT rejectedPinSet FROM ttt WHERE sq = (SELECT ord+1 FROM test))) AS rej(pin) UNION
SELECT (SELECT ord+1 FROM test), pin, 'a' FROM TABLE ((SELECT acceptedPinSet FROM ttt WHERE sq = (SELECT ord+1 FROM test))) AS acp(pin))
) SELECT * FROM test
The following test fails too:
SELECT sq, pin
FROM ttt AS t1
JOIN TABLE ((SELECT rejectedPinSet FROM ttt WHERE sq = t1.sq)) AS rej(pin)
------------------------------
Zambrano, Hugo
Informix DBA
Ottawa Police
Ottawa, ON
(613)236-1222, 5575
------------------------------
#Informix