2025-05-17

找出所有的父表:
Java代碼 
With reftables(reftabname,PRIORITY) as(  
Select reftabname,1 from syscat.references as refx where refx.tabname=PROJECT 
union all  
Select ref2.reftabname,reftables.PRIORITY+1 from reftables,syscat.references ref2 where reftables.reftabname=ref2.tabname  
)  
Select * from reftables ORDER BY PRIORITY DESC; 


With reftables(reftabname,PRIORITY) as(
Select reftabname,1 from syscat.references as refx where refx.tabname=PROJECT
union all
Select ref2.reftabname,reftables.PRIORITY+1 from reftables,syscat.references ref2 where reftables.reftabname=ref2.tabname
)
Select * from reftables ORDER BY PRIORITY DESC;



找出所有的子表
Java代碼 
With reftables(tabname,PRIORITY) as(  
Select tabname,1 from syscat.references as refx where refx.reftabname=PROJECT 
union all  
Select ref2.tabname,reftables.PRIORITY+1 from reftables,syscat.references ref2 where reftables.tabname=ref2.reftabname  
)  
Select distinct * from reftables ORDER BY PRIORITY DESC; 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *