oracle中depends,oracle 获取某个包 依赖的所有对象包括其子对象

这段代码展示了如何遍历Oracle数据库中的程序包依赖关系。它定义了两个游标,一个用于获取指定程序包的依赖项,另一个用于递归地查找子依赖项。代码将依赖关系插入到临时表中,并打印出子节点信息。该过程用于构建程序包的依赖树。
摘要由CSDN通过智能技术生成

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

declare

-- 获取相应的 某个程序包 所需要应用的包

cursor p_cur(p_name varchar2) is

select dd.name,dd.type,dd.referenced_name,dd.referenced_type

from dba_dependencies dd

where 1 = 1

and dd.referenced_type in

('PACKAGE','SYNONYM','TABLE','SEQUENCE')

and dd.type in ('PACKAGE','PACKAGE BODY')

AND dd.name = p_name;

cursor p_temp(l_level number) is

select attribute1,attribute2

from cux_common_imports_temp

where attribute2 = l_level;

p_root_name varchar2(30);

p_level number := 0;

p_count number := 0;

begin

--将根节点 放入到表中

p_root_name := 'CUX_SBU_COMMON';

insert into cux_common_imports_temp

(attribute1,attribute2)

values

(p_root_name,p_level);

p_count := 1;

--循环这一层的 节点 并获得其子节点

while p_count != 0 loop

for p_loop in p_temp(p_level) loop

--下一层

p_level := p_level + 1;

p_root_name := p_loop.attribute1;

for p_rec in p_cur(p_root_name) loop

if p_rec.referenced_type = 'PACKAGE' then

--如果表内 没有这个程序就 加入到 临时表中

select count(*)

into p_count

from cux_common_imports_temp

where attribute1 = p_rec.referenced_name;

if p_count = 0 then

insert into cux_common_imports_temp

(attribute1,attribute2)

values

(p_rec.referenced_name,p_level);

end if;

--输出相应的 子节点信息

dbms_output.put_line(p_level || '-Name:' ||

p_rec.referenced_name || '-Type:' ||

p_rec.referenced_type);

end if;

end loop;

end loop;

--获取 该层是否为空

select count(*)

into p_count

from cux_common_imports_temp

where attribute2 = p_level;

end loop;

end;

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值