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;
原文:http://www.cnblogs.com/weihongli/p/6296904.html