Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> ORA-00164: Autonomous Transaction Disallowed Within Distributed Transaction
Hi,
I have been getting error 'ORA-00164: Autonomous Transaction Disallowed Within Distributed Transaction' in my PL/SQL code. I have found exactly why it appears,but have not been able to find a work around.
I need to get information through a dblink that calls a stored procedure, and returns various information to my procedure. Before and after this call, I may have pending incomplete transactions, so I am unable to do a commit before or after the dblink call.
After the dblink call I have been using the pragma autonomous transaction, so that I can find a value for a field at the time of the last commit. I am unable to get the value before the dblink call, as the code is called within a proprietary package.
To try to overcome/investigate the problem, I have written the sample code below, with the output as shown after it:
declare
v varchar2(1000);
-- procedure x has autonomous trans
procedure x is
PRAGMA AUTONOMOUS_TRANSACTION;
begin
pkg_pipe.putline('x started');
null;
exception
when others then
pkg_pipe.putline('errorx'); pkg_pipe.putline(sqlerrm);
Now once this runs, I get the following output. You will note that none of the exception handlers will catch the ORA-00164, and that I'm unable to close the database (in use).
This is the output from the pipe, so that I can see things real time.
14:34:34 x start 14:35:45 getting Details on object 123456 14:35:45 return from mydblink No Data returned from mydblink 14:35:46 z starting 14:35:46 y start 14:35:46 closing mydblink 14:35:46 errory 14:35:46 ORA-02080: database link is in use 14:35:46 x start
Now in SQL*Plus , you get the ERROR, no exception handler appears to catch it.
unixerror says:
oerr ora 02080
02080, 00000, "database link is in use"
// *Cause: a transaction is active or a cursor is open on the database // linkgiven in the alter session close database link <link> command. // *Action: commit or rollback, and close all cursors
Remember I can't commit, or rollback, there may be incomplete/pending updates before and after the query.
Asking around, here is one response I got, but I was hoping that there was something that could be done. Darn Oracle8.1.7+ !!!
"Capturing the error __WILL NOT__ solve the problem. You will likely cause even worse things to happen! You must close the database link __BEFORE__ the autonomous transaction is started; if the database link is active (ie transaction is actually open) you are screwed -- there is nothing that you can do."
Is there a way around the Database link is in use, or some other way to close the link, or is there a way to capture the 00164 error?
Thanks,
Darren Received on Thu Nov 07 2002 - 23:11:46 CST