我有一个表,其中包含表示层次结构的数据。从该表中获取单个“对象”的数据的最简单方法是递归查询。同一个表还存储与“对象”关联的“成员变量”。我认为在单个查询中查看对象结构以及关联的成员变量会很好,所以我尝试了类似的方法:
cursor object_explorer is
select (level*2) lvl, ob.object_id, lpad(ot1.object_type_name, 2*level + length(ot1.object_type_name), '.') ob_typ_nam
from obj_tab ob, obj_type ot1
, cursor (select lpad(mv.member_var_name, level + length(mv.member_var_name), ' ') var_nam, /*other stuff*/
from obj_type ot2, object_memberVar_value omv, member_variable mv
where mv.member_variable_id = omv.member_variable_id
and ot2.object_type_id = omv.object_type_id
and omv.object_id = ob.object_id)
where ot1.object_type_id = ob.object_type_id
and /*other filtering conditions unrelated to problem at hand*/
start with ob.objecT_id = '1234567980ABC'
connect by nocycle ob.parent_object = prior ob.object_id;
...并且 Oracle 告诉我“不允许使用光标表达式”。
如果我将其作为两个单独的游标(循环遍历一个游标的结果,然后根据这些结果使用另一个游标),则一切正常,因此我不需要单游标解决方案。
我只是想知道为什么我不能使用游标表达式组合这两个查询 - 或者我可以组合它们而我只是以某种方式错过了它?
(Oracle版本为10g)