Oracle 10g:在视图内订购单

问题描述

|| 是否可以在视图内添加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:右括号缺失     

解决方法

        您是否尝试过删除括号:
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;