1.01^365=37.8 0.99^365=0.03
分类: Oracle
2015-11-19 10:54:28
现象:
数据库1(db1)上过程p1通过dblink调用数据库2(db2)上的过程p2
当db2上p2中的内容改变后,重新编译后,再重新编译db1上的p1是没问题的,但运行p1时就回报错: --注意是运行时报错
Error: ORA-04062: timestamp of procedure has been changed
经过查询一些资料,得知是REMOTE_DEPENDENCIES_MODE = { TIMESTAMP | SIGNATURE } 导致的
11.2oracle文档解释:
REMOTE_DEPENDENCIES_MODEProperty Description
Parameter type String
Syntax REMOTE_DEPENDENCIES_MODE = { TIMESTAMP | SIGNATURE }
Default value TIMESTAMP
Modifiable ALTER SESSION, ALTER SYSTEM
REMOTE_DEPENDENCIES_MODE specifies how Oracle should handle dependencies upon remote PL/SQL stored procedures.
Values:
?TIMESTAMP
The client running the procedure compares the timestamp recorded on the server-side procedure with the current timestamp of the local procedure and executes the procedure only if the timestamps match.
?SIGNATURE
Oracle allows the procedure to execute as long as the signatures are considered safe. This setting allows client PL/SQL applications to be run without recompilation.
以上的timestamp 是等价于dba_objests里面的timestamp 列值,测试:
SQL> create procedure p
SQL> select last_ddl_time, timestamp from user_objects where object_name = 'P';
以上测试说明:
all_objects中的last_ddl_time包括了grant,同时也包括了revoke ;create procedure会直接变成 create or replace procedure ,使用pl/sql developer
会改变timestamp 值,但sqlplus 不会;如果过程的内容改变了,不管使用哪个工具timestamp都会改变
所以解决以上错误只有以下2种方式:
1:alter procedure xxx compile; --运行过程前提前把含有dblink过程编译一下
2:alter session set remote_dependencies_mode=signature;
在p1的过程中在引用dblink过程之前增加:
EXECUTE IMMEDIATE 'alter session set remote_dependencies_mode=signature';
即可解决问题。