是否可以在视图中添加ORDER SIBLINGS BY fieldName? 我有一个层次结构,我成功地使用了CONNECT BY功能的查询。
但是,当我在视图定义中添加ORDER SIBLINGS BY fieldName时,Oracle会给出一个奇怪的括号错误。
drop view myview;
create view myview as (
select id, level as depth, label, parentid, orderhint,
connect_by_root myfield1 "myfield1", connect_by_root id "toplevelparentid"
from mytable
connect by prior id = parentid
start with id in (select id from mytable where parentid is null)
order siblings by orderhint
);
如果没有ORDER SIBLINGS BY或在视图定义之外,它就像魅力一样。否则,我得到:
ORA-00907:缺少右括号
答案 0 :(得分:2)
您是否尝试删除括号:
drop view myview;
create view myview as
select id, level as depth, label, parentid, orderhint,
connect_by_root myfield1 "myfield1", connect_by_root id "toplevelparentid"
from mytable
connect by prior id = parentid
start with id in (select id from mytable where parentid is null)
order siblings by orderhint;