日期:2014-05-16  浏览次数:20414 次

db2 递归函数小示例

with rpl(id,name,parent) as (

select id,name,parent from A_ORGAN where id=999

union all

select t1.id,t1.name,t1.parent from rpl t2,A_ORGAN t1 where t2.id=t1.parent

)

select distinct id,name,parent from rpl order by id asc

?

select t1.id,t1.name from A_ORGAN t1 where ?t1.ID=999 or t1.PARENT=999 order by t1.id asc