and if you just execute it again, what happens. that is something catchable and correctable. ok, I see, this one works:
sokrates@11.2 [remote] create or replace function f return int is begin return 1; end f;
2 /
Function created.
and
sokrates@11.2 [local] create or replace package p is
2 procedure p;
3 end p;
4 /
Package created.
sokrates@11.2 [local] create or replace package body p is
2 procedure p( vrecursive_count in int ) is
3 ts_of_remote_proc_changed exception;
4 pragma exception_init( ts_of_remote_proc_changed, -4062 );
5 begin
6
7 if vrecursive_count > 1 then
8 raise_application_error(-20999, 'vrecursive_count > 1');
9 end if;
10
11 begin
12 execute immediate 'begin dbms_output.put_line(f@loopback); end;';
13 exception when ts_of_remote_proc_changed then
14 dbms_output.put_line('ts_of_remote_proc_changed ! - remotecall once again');
15 p( vrecursive_count => vrecursive_count + 1);
16 end;
17 end p;
18
19 procedure p is
20 begin
21 p ( vrecursive_count => 0 );
22 end p;
23 end p;
24 /
Package body created.
sokrates@11.2 [local] exec p.p
1
PL/SQL procedure successfully completed.
sokrates@11.2 [remote] create or replace function f return int is begin return 2; end f;
2 /
Function created.
now
sokrates@11.2 [local] exec p.p
ts_of_remote_proc_changed ! - remotecall once again
2
PL/SQL procedure successfully completed.
and we have
sokrates@11.2 [local] select referenced_type, referenced_name
2 from user_dependencies
3 where name='P' and type = 'PACKAGE BODY' and referenced_link_name = 'LOOPBACK';
no rows selected
I would have expected the same behaviour not using dynamic sql, since the STATUS of package P doesn't change when dependent objects change remotely. But the behaviour is not the same:
sokrates@11.2 [local] create or replace package body p is
2
3 procedure p( vrecursive_count in int ) is
4 ts_of_remote_proc_changed exception;
5 pragma exception_init( ts_of_remote_proc_changed, -4062 );
6 begin
7
8 if vrecursive_count > 10 then
9 raise_application_error(-20999, 'vrecursive_count > 10');
10 end if;
11
12 begin
13 dbms_output.put_line(f@loopback);
14 exception when ts_of_remote_proc_changed then
15 dbms_output.put_line('ts_of_remote_proc_changed ! - remotecall once again');
16 p( vrecursive_count => vrecursive_count + 1);
17 end;
18 end p;
19
20 procedure p is
21 begin
22 p ( vrecursive_count => 0 );
23 end p;
24 end p;
25 /
Package body created.
now, we have
sokrates@11.2 [local] select referenced_type, referenced_name
2 from user_dependencies
3 where name='P' and type = 'PACKAGE BODY' and referenced_link_name = 'LOOPBACK';
REFERENCED_TYPE REFERENCED_NAME
------------------------------ ------------------------------
FUNCTION F
sokrates@11.2 [local] exec p.p
2
PL/SQL procedure successfully completed.
sokrates@11.2 [remote] create or replace function f return int is begin return 3; end f;
2 /
Function created.
and then local:
sokrates@11.2 [local] select status, object_type from user_objects where object_name='P';
STATUS OBJECT_TYPE
------- -------------------
VALID PACKAGE
VALID PACKAGE BODY
however, -4062 seems to be raised infinitely open:
sokrates@11.2 [local] exec p.p
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
ts_of_remote_proc_changed ! - remotecall once again
BEGIN p.p; END;
*
ERROR at line 1:
ORA-20999: vrecursive_count > 10
ORA-06512: at "SOKRATES.P", line 9
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 16
ORA-06512: at "SOKRATES.P", line 22
ORA-06512: at line 1
So, we really
have to recompile the caller in order to pick up the new timestamp. http://docs.oracle.com/cd/E11882_01/server.112/e17766/e2100.htm#sthref1897 I don't really see the idea behind this implemented behaviour especially we can simply workaround it by using dynamic sql.