我有以下sql代码在APEX中生成一个树:
select 1 as status, 1 pid, 'Fehlermeldungen' as titel, null as icon, '1' as value, NULL as tooltip, NULL as link from dual
union
select -1 as status, 2 pid, k.kname as titel, NULL as icon, k.knr||'0' as value, NULL as tooltip, NULL as link from kunde k where
(select count(fmtext) from fehlermeldung f where f.knr = k.knr) > 0
union
select 0 as status, 3 pid, fmtext as titel, NULL as icon, k.knr||fmnr as value, NULL as tooltip, null as link from kunde k, fehlermeldung f where f.knr = k.knr
order by value
现在,我想添加第四层,但如果我尝试使用pid = 4创建另一个联合,则该条目将附加到最后一个选择。 我该如何管理?
答案 0 :(得分:1)
首先,我尝试重新格式化您的代码。看来你所描述的应该可以正常工作。我假设你尝试过这样的事情:
select 1 as status, 1 pid, 'Fehlermeldungen' as titel, null as icon, '1' as value,
NULL as tooltip, NULL as link from dual
union
select -1 as status, 2 pid, k.kname as titel, NULL as icon, k.knr||'0' as value,
NULL as tooltip, NULL as link from kunde k
where (select count(fmtext) from fehlermeldung f where f.knr = k.knr) > 0
union
select 0 as status, 3 pid, fmtext as titel, NULL as icon, k.knr||fmnr as value,
NULL as tooltip, null as link from kunde k, fehlermeldung f
where f.knr = k.knr
-- begin my new lines...
union
select 0 as status, 4 pid, 'blank' as titel, NULL as icon, '4' as value,
NULL as tooltip, null as link from dual
-- end my new lines...
order by 5
是否有可能将其他SELECT插入错误的位置?告诉我们你做了什么,并且更容易排除故障。