当前位置:Gxlcms > mysql > oracle获取某个包依赖的所有对象包括其子对象

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

时间:2021-07-01 10:21:17 帮助过:6人阅读

使用了一个一个临时表 记录了已经遍历的 节点 同时 使用了层数来记录已经遍历的 包 PL/SQL dba_dependencies Oracle declare -- 获取相应的 某个程序包 所需要应用的包 cursor p_cur(p_name varchar2) is select dd.name, dd.type, dd.referenced_name, dd.re

使用了一个一个临时表 记录了已经遍历的 节点
同时 使用了层数来记录已经遍历的 包 PL/SQL dba_dependencies Oracle
  1. declare
  2. -- 获取相应的 某个程序包 所需要应用的包
  3. cursor p_cur(p_name varchar2) is
  4. select dd.name, dd.type, dd.referenced_name, dd.referenced_type
  5. from dba_dependencies dd
  6. where 1 = 1
  7. and dd.referenced_type in
  8. ('PACKAGE', 'SYNONYM', 'TABLE', 'SEQUENCE')
  9. and dd.type in ('PACKAGE', 'PACKAGE BODY')
  10. AND dd.name = p_name;
  11. cursor p_temp(l_level number) is
  12. select attribute1, attribute2
  13. from cux_common_imports_temp
  14. where attribute2 = l_level;
  15. p_root_name varchar2(30);
  16. p_level number := 0;
  17. p_count number := 0;
  18. begin
  19. --将根节点 放入到表中
  20. p_root_name := 'CUX_SBU_COMMON';
  21. insert into cux_common_imports_temp
  22. (attribute1, attribute2)
  23. values
  24. (p_root_name, p_level);
  25. p_count := 1;
  26. --循环这一层的 节点 并获得其子节点
  27. while p_count != 0 loop
  28. for p_loop in p_temp(p_level) loop
  29. --下一层
  30. p_level := p_level + 1;
  31. p_root_name := p_loop.attribute1;
  32. for p_rec in p_cur(p_root_name) loop
  33. if p_rec.referenced_type = 'PACKAGE' then
  34. --如果表内 没有这个程序就 加入到 临时表中
  35. select count(*)
  36. into p_count
  37. from cux_common_imports_temp
  38. where attribute1 = p_rec.referenced_name;
  39. if p_count = 0 then
  40. insert into cux_common_imports_temp
  41. (attribute1, attribute2)
  42. values
  43. (p_rec.referenced_name, p_level);
  44. end if;
  45. --
输出相应的 子节点信息 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;

人气教程排行