Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ORA-2020 when trying to verify database links

548625Oct 29 2007 — edited Oct 29 2007
I have a problem with verifying database links. I want to create a procedure for checking all database links. this is done like the following:

declare
xRefCursor sys_refcursor;
cursor cDBLinks is
select db_link
from user_db_links;
nDummy number;
begin
for rL in cDBLinks loop
begin
open xRefCursor for 'select 1 from dual@'||rL.db_link;
fetch xRefCursor into nDummy;
close xRefCursor;
dbms_output.put_line(rL.db_link||' established');
exception
when others then
if xRefCursor%isopen then
close xRefCursor;
end if;
dbms_output.put_line(rL.db_link||' error '||sqlerrm);
end;
end loop;
end;

when running the procedure, I get a ORA-2020 : too many database links in use

Cause: The current session has exceeded the INIT.ORA OPEN_LINKS maximum.

Action: Increase the OPEN_LINKS limit, or free up some open links by committing or rolling back the transaction and canceling open cursors that reference remote databases

exact after the count of database links specified in the OPEN_LINKS parameter. As you can see I don't issue any transaction, and also I close every cursor I open...so there should be just one db link active in time. note that increasing the OPEN_LINKS parameter will not be a good solution, as I can't tell how much links are existing for a user.

any suggestions?
regards
Christian

oh, forgot to mention: tried this with 9.2.0.6 and 10.2.0.3 on WINDOWS (so I believe this also occurs in 9.2.0.6 <= DBVersion <= 10.2.0.3)

Message was edited by:
W1zard
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2007
Added on Oct 29 2007
6 comments
4,734 views