Учитывая эту схему:
create table a (id int);
create table b (id int, a_id int, c_id int);
create table c (id int);
insert into a values (1);
insert into a values (2);
insert into b values (1, 1, 1);
insert into b values (2, 1, 1);
insert into b values (3, 2, 4);
insert into b values (4, 2, 2);
insert into c values (1);
insert into c values (2);
insert into c values (3);
insert into c values (4);
Я попытался выполнить такой запрос:
select
a.id,
multiset(
select
b.id,
multiset(
select c.id
from c
where c.id = b.c_id
)
from b
where b.a_id = a.id
) m
from a
order by a.id
Но вывод показывает, что внутренний самый вложенный запрос MULTISET
не работает. Результат:
id 1
m MULTISET{ROW(1,MULTISET{}),ROW(2,MULTISET{})}
id 2
m MULTISET{ROW(3,MULTISET{}),ROW(4,MULTISET{})}
Это известное ограничение или ошибка? Как я могу обойти это ограничение? Я использую IBM Informix Dynamic Server версии 14.10.FC5DE.
Точно так же, как аналогичная проблема, которую я обнаружил недавно, кажется, есть ошибка, связанная с ORDER BY
. Удаление пункта ORDER BY
:
select
a.id,
multiset(
select
b.id,
multiset(
select c.id
from c
where c.id = b.c_id
)
from b
where b.a_id = a.id
) m
from a
И результат теперь ожидаемый:
id 1
m MULTISET{ROW(1,MULTISET{ROW(1)}),ROW(2,MULTISET{ROW(1)})}
id 2
m MULTISET{ROW(3,MULTISET{ROW(4)}),ROW(4,MULTISET{ROW(2)})}
Определенно кажется, что это ошибка в Informix.