db2 递归函数小示范

db2 递归函数小示例with rpl(id,name,parent) as (select id,name,parent from A_ORGAN where id999union

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.parentfrom rpl t2,A_ORGAN t1 where t2.id=t1.parent

)

selectdistinct id,name,parent from rpl order by id asc

?

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