首页 > Linux操作系统 > Linux操作系统 > PL/SQL包可以打破依赖链
做一下实验:
创建过程p1、p2
create or replace procedure p1
is
begin
null;
end;
/
create or replace procedure p2
is
begin
p1;
end;
/
select object_name, status
from user_objects
where object_name in ('P1','P2')
/
OBJECT_NAM STATUS
---------- --------------
P1 VALID
P2 VALID
select name, type, referenced_name, referenced_type
from user_dependencies
where name = 'P2'
/
NAME TYPE REFERENCED REFERENCED_TYPE
--------- --------- ---------- -------------------
P2 PROCEDURE P1 PROCEDURE
可以看到p2依赖于p1,状态都是VALID,当p1更改时
create or replace procedure p1
is
begin
dbms_output.put_line('abc');
end;
/
再次查看状态发现
OBJECT_NAM STATUS
---------- --------------
P1 VALID
P2 INVALID
p2为INVALID
SQL> exec p2;
abc
PL/SQL 过程已成功完成。
执行p2能够成功,因为在执行前p2被重新编译了一遍。
如果把这两个过程打包
create or replace package p1 is
procedure p1;
end;
/
create or replace package body p1 is
procedure p1
is
begin
null;
end;
end;
/
create or replace package p2 is
procedure p2;
end;
/
create or replace package body p2 is
procedure p2
is
begin
p1.p1;
end;
end;
/
SQL> select object_name, status
2 from user_objects
3 where object_name in ('P1','P2')
4 /
OBJECT_NAM STATUS
---------- --------------
P1 VALID
P1 VALID
P2 VALID
P2 VALID
更改p1
create or replace package body p1 is
procedure p1
is
begin
dbms_output.put_line('abc');
end;
end;
/
SQL> select object_name, status
2 from user_objects
3 where object_name in ('P1','P2')
4 /
OBJECT_NAM STATUS
---------- --------------
P1 VALID
P1 VALID
P2 VALID
P2 VALID
status仍然不变
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25361369/viewspace-704822/ ,如需转载,请注明出处,否则将追究法律责任。