将子节点的所有父节点ID合并成一个字符串,并更新表

begin
for cur_dept in (select SLCATALOG_ID from T_GIS_SLCATALOG) loop
UPDATE T_GIS_SLCATALOG
SET PATH =
(SELECT listagg(SLCATALOG_ID, ',') WITHIN GROUP (ORDER BY SLCATALOG_ID)
FROM (SELECT *
FROM T_GIS_SLCATALOG
START WITH SLCATALOG_ID = cur_dept.SLCATALOG_ID
CONNECT BY PRIOR PARENT_ID = SLCATALOG_ID))
WHERE SLCATALOG_ID = cur_dept.SLCATALOG_ID;
end loop;
end;

posted @ 2017-01-18 15:30  忆如梨花  阅读(286)  评论(0编辑  收藏  举报