oracle 通过编码自动修改父子级和级次,叶子节点

UPDATE p#BIM_INC_EXP_SORT a
SET (a.parentid, a.levelno, a.isleaf) =
(SELECT b.parentid, b.levelno, b.isleaf
FROM (select unqguid,
(select max(unqguid)
from p#BIM_INC_EXP_SORT
where code = substr(t.code, 1, len(t.code) - 2)) parentid,
LEVEL levelno,
connect_by_isleaf isLeaf
from p#BIM_INC_EXP_SORT t
start with len(code) = 3
connect by prior code = substr(code, 1, len(code) - 2)) b
WHERE a.unqguid = b.unqguid)
WHERE 1 = 1

原文地址:https://www.cnblogs.com/sx2zx/p/12855983.html