oracle ORA-03150: 数据库链接的通信通道上的文件结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47989846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:29:40  来源:igfitidea点击:

ORA-03150: end-of-file on communication channel for database link

sqloracleexceptiondatabase-link

提问by detoro84

In an Oracle database there's a big PL/SQL procedure being executed periodically that copies data from one DB to another one through a database link and it is failing after some hours with the following error:

在 Oracle 数据库中,定期执行一个大型 PL/SQL 过程,该过程通过数据库链接将数据从一个数据库复制到另一个数据库,并且在几个小时后失败并出现以下错误:

ORA-03150: end-of-file on communication channel for database link 
ORA-02063: preceding line from DBPREMOTE 
ORA-06512: at "DBLOCAL.JOB_NAME", line 710 
...
ORA-06512: at line 1 

Line 710 is the first line of a procedure:

第 710 行是程序的第一行:

 execute immediate 'set constraints all deferred';

Then the procedure does some inserts and updates, which I guess are failing at some point due to PK, data not valid or whatever other reason. I guess that the exception is being pointing at that line because it is the first one, not because it is actually failing there, but I don't know for sure the real exception.

然后该过程执行一些插入和更新,我猜由于 PK、数据无效或其他任何原因,这些操作在某些时候会失败。我想异常指向那条线是因为它是第一个,而不是因为它实际上在那里失败了,但我不确定真正的异常。

Is there any chance I can get the real exception so I can handle it?

我有没有机会得到真正的异常以便我可以处理它?

回答by Wernfried Domscheit

A potential workaround could be to close the DB-Link after eachusage with a PL/SQL procedure like this:

一个潜在的解决方法可能是在每次使用后使用 PL/SQL 过程关闭 DB-Link,如下所示:

FOR aLink IN (SELECT * FROM V$DBLINK) LOOP
    DBMS_SESSION.CLOSE_DATABASE_LINK(aLink.DB_LINK);
END LOOP;

or

或者

DECLARE
    DATABASE_LINK_IS_NOT_OPEN EXCEPTION;
    PRAGMA EXCEPTION_INIT(DATABASE_LINK_IS_NOT_OPEN, -2081);
BEGIN
    DBMS_SESSION.CLOSE_DATABASE_LINK('DBPREMOTE ');
EXCEPTION 
    WHEN DATABASE_LINK_IS_NOT_OPEN THEN 
        NULL;
END;

If the connections are dropped anyway, you should talk to your network guys. Perhaps they drop the connection by firewall settings. However, there could be many others reasons.

如果无论如何连接都断开了,您应该与您的网络人员交谈。也许他们通过防火墙设置断开连接。但是,可能还有许多其他原因。