3 和 5。
但是不要相信我的话,让我们测试一下。
创建测试对象
--Remote dependency mode
alter session set remote_dependencies_mode = timestamp;
--Table
drop table emp purge;
create table emp(id number, name varchar2(100));
insert into emp values(1, 'asdf');
commit;
--Database link - you don't need two databases, you can link to yourself
drop database link myself;
create database link myself connect to <user> identified by <password> using '<database>';
select * from dual@myself;
--Procedures
create or replace procedure process_emp(action_type in varchar2) is
v_count number;
begin
if action_type = 'U' then
update emp set name = upper(name);
elsif action_type = 'Q' then
select count(*) into v_count from emp;
end if;
end;
/
create or replace procedure update_emp is
begin
process_emp('U');
end;
/
create or replace procedure query_emp is
begin
process_emp@myself('Q');
end;
/
--Initial object times
select object_name, last_ddl_time, status
from user_objects
where object_name in ('PROCESS_EMP', 'UPDATE_EMP', 'QUERY_EMP')
order by last_ddl_time;
PROCESS_EMP 2013-04-02 00:25:47 VALID
UPDATE_EMP 2013-04-02 00:25:48 VALID
QUERY_EMP 2013-04-02 00:25:49 VALID
测试
1)如果PROCESS_EMP过程的签名被修改并成功重新编译,则EMP表无效。
错误- 甚至没有什么可以测试的。没有无效表之类的东西。(可能对象关系表除外,但我认为这不适用于这里。)
2) 如果PROCESS_EMP过程的内部逻辑被修改并成功重新编译,则UPDATE_EMP失效并在第一次调用时重新编译。
False - UPDATE_EMP 仍然有效,并且不会重新编译。LAST_DDL_TIME 不会改变。通常,一个过程只通过它的签名知道——如果它没有改变,那么就没有必要改变其他任何东西。
create or replace procedure process_emp(action_type in varchar2) is
v_count number;
begin
if action_type = 'U' then
update emp set name = upper(name);
elsif action_type = 'Q' then
select count(*)+1 into v_count from emp;
end if;
end;
/
select object_name, last_ddl_time, status
from user_objects
where object_name in ('PROCESS_EMP', 'UPDATE_EMP', 'QUERY_EMP')
order by last_ddl_time;
UPDATE_EMP 2013-04-02 00:25:48 VALID
QUERY_EMP 2013-04-02 00:25:49 VALID
PROCESS_EMP 2013-04-02 00:29:20 VALID
3) 如果PROCESS_EMP 过程的签名被修改并成功重新编译,UPDATE_EMP 将失效并在第一次调用时重新编译。
True - 更改参数可能会更改调用过程的方式。大多数更改都会导致失败,但在许多情况下,依赖过程将重新编译并且一切都会好起来的。例如,如果您添加一个默认参数:
create or replace procedure process_emp(action_type in varchar2, new_param in varchar2 default null) is
v_count number;
begin
if action_type = 'U' then
update emp set name = upper(name);
elsif action_type = 'Q' then
select count(*)+1 into v_count from emp;
end if;
end;
/
--Now the object is invalid:
select status from user_objects where object_name in ('UPDATE_EMP');
INVALID
--But no need to worry, just run it and it will automatically recompile and work correctly:
begin
update_emp;
end;
/
select status from user_objects where object_name in ('UPDATE_EMP');
VALID
4) 如果PROCESS_EMP 过程的内部逻辑被修改并成功重新编译,则QUERY_EMP 将失效并在第一次调用时重新编译。
False - QUERY_EMP 仍然有效,但在第一次调用时会失败,并且不会重新编译。事实上,即使像我们上面所做的那样更改参数也不会使这一点无效。
select object_name, last_ddl_time, status
from user_objects
where object_name in ('QUERY_EMP')
order by last_ddl_time;
QUERY_EMP 2013-04-02 00:25:49 VALID
begin
query_emp@myself;
end;
/
ORA-04062: timestamp of procedure "JHELLER.PROCESS_EMP" has been changed
ORA-06512: at "JHELLER.QUERY_EMP", line 3
ORA-06512: at line 2
View program sources of error stack?
5) 如果PROCESS_EMP 过程的内部逻辑被修改并成功重新编译,则QUERY_EMP 将失效并在第二次调用时重新编译。
True - QUERY_EMP 将失效(尽管直到第一次之后),然后第二次正确重新编译。查询运行,并且 LAST_DDL_TIME 现在已更新。
begin
query_emp@myself;
end;
/
select object_name, last_ddl_time, status
from user_objects
where object_name in ('QUERY_EMP')
order by last_ddl_time;
QUERY_EMP 2013-04-02 00:37:01 VALID