Oracle 10g:VIEW中的ORDER SIBLINGS

时间:2011-06-16 14:05:34

标签: sql oracle oracle10g sql-order-by ora-00907

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

1 个答案:

答案 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;