开发者

Oracle 10g : ORDER SIBLINGS inside a VIEW

开发者 https://www.devze.com 2023-03-13 05:49 出处:网络
Is it possible to add a ORDER SIBLINGS BY fieldName inside a view? I\'ve got a hierarchical structure, in which I\'m successfully using a query with the CONNECT BY feature.

Is it possible to add a ORDER SIBLINGS BY fieldName inside a view? I've got a hierarchical structure, in which I'm successfully using a query with the CONNECT BY feature.

However, when I add the ORDER SIBLINGS BY fieldName inside the view definition, Oracle gives a strange parenthesis error.

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开发者_StackOverflow from mytable where parentid is null)
  order siblings by orderhint
);

Without the ORDER SIBLINGS BY or outside a view definition it works like a charm. Otherwise, I get:

ORA-00907: Missing right parenthesis


Have you tried removing your parentheses:

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消