oracle 报错 :ORA-04052、 ORA-00604、 ORA-03106、 ORA-02063

最近发现一个很奇怪的问题:

创建了一个DB_LINK连接另一个Oracle数据库。

select * from tablename@dblinkname;

单句执行没问题,但是把这句SQL写到存储过程内:

create or replace procedure prc_test
is
begin
insert into test
select * from tablename@dblinkname;
commit;

end;

就发生如下错误,存储过程编译不通过:

报错如下:PACKAGE BODY SKSKJ.PKG_TS 编译错误

错误:PL/SQL:

       ORA-04052: error occurred when looking up remote object DZDZ_123.SM123@DZDZ123
       ORA-00604: error occurred at recursive SQL level 1
       ORA-03106: fatal two-task communication protocol error
       ORA-02063: preceding line from DZDZ_SJTS
行:32
文本:insert into sm123@DZDZ123

也不是所有的数据库都有这样的问题。
 
哪位大侠遇到过这样的问题,能否给个解决方案?非常感谢!
 
 
附:创建dblink的脚本:
 
-- Drop existing database link
drop database link dblink1;
-- Create database link
create database link dblink1
  connect to username123 identified by passwd123
  using '(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.*.*)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = 123)
    )
  )';

 
drop synonym test;
create synonym test for test@dblink1;





--metalink上解决问题方法,打上对应的补丁就解决了。

Subject:  Errors ORA-00604 And ORA-03106 During Procedure Compilation
  Doc ID:  577347.1 Type:  PROBLEM
  Modified Date :  26-MAY-2008 Status:  MODERATED


Applies to:
PL/SQL - Version: 9.2.0.4 to 9.2.0.8
This problem can occur on any platform.
This note applies only if the underlying Oracle Client is below 9.2.0.8 Patch 4


Symptoms
While trying to run pl/sql code involving queries which access remote objects, you may endup getting below errors:

PL/SQL: ORA-04052: error occurred when looking up remote object <object name>
ORA-00604: error occurred at recursive SQL level 1
ORA-03106: fatal two-task communication proto error
ORA-02063: preceding line from AFQ

When the same query is run outside pl/sql block it runs perfectly.

Cause
You are most probably hitting the Bug 5866805.
Bug 5866805 duplicate of Bug 5576340 which is itself a duplicate of Bug 5671074.


Solution
The Bug 5671074 IS fixed IN 9.2 .0 .8 Patch 4 OR above.

原文地址:https://www.cnblogs.com/iyoume2008/p/4865053.html