表信息
要查詢出節點super_code的對應的id值,下面是遞歸方法:
WITH m AS (
SELECT dept_id id, dept_code code,dept_name label,CAST ('' AS VARCHAR(50)) parent,is_last leaf
FROM sys_dept WHERE is_stop = '0' and comp_code= '1001' and super_code='-1'
UNION ALL
SELECT c.dept_id id,c.dept_code code,c.dept_name label,CAST (m.id AS VARCHAR(50)) parent,c.is_last leaf
FROM sys_dept c ,m
where c.super_code = m.code and is_stop = '0' and comp_code= '1001'
)
select * from m
查詢結果:
Oracle的遞歸方法,請查看以前發的博客點擊鏈接--- 點我點我,帶你飛,oracle遞歸