oracle 获取 tree的路径问题

来源:互联网 发布:龙年瞎子皮肤淘宝多钱 编辑:程序博客网 时间:2024/06/11 04:37
select c.container_id,
     (select listagg(m.container_name, '/') within group(order by level desc) tpath
        from container m
       start with m.container_id = c.container_id
      connect by prior m.parent_id = m.container_id) containerPath

from container c

这样可以获取每个节点的节点路径,listagg是11g的一个连接函数,用法为 listagg(col_name,"seperator") within group(order by level desc),col_name为要拼接的列名称,seperator是以什么为分隔符,由于项目较紧,只能先写到这了,如果有啥问题,希望大家在线交流。以后再详细补充这个问题

0 0
原创粉丝点击