Oracle 10g:在视图中订购SILINGS



是否可以在视图中添加ORDER SIBLINGS BY fieldName?我有一个层次结构,在其中我成功地使用了具有CONNECTBY特性的查询。

但是,当我在视图定义中添加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;

相关内容

  • 没有找到相关文章

最新更新