Home » RDBMS Server » Server Administration » Open Database Links
Open Database Links [message #58918] Mon, 13 October 2003 12:30 Go to next message
Dan White
Messages: 48
Registered: September 2003
Member
We have an Issue with Open Links. After see many other posts on other boards we know that we can alter session close database link. Where we have the issue is this. We have an anonymous PL/SQL block that does the following.

Declare
cursor c
is
select a from table@database2;

begin
open c;
fetch c.......
close c;
commit;
execute immediate
'alter session close database link database2';
end;
/

When we run this block we get an error that the dblink is still active. is there any way to correct this?
Re: Open Database Links [message #58919 is a reply to message #58918] Mon, 13 October 2003 12:43 Go to previous message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
Try closing the link after the anonymous block has been executed.

thiru@9.2.0:SQL>declare
2 cursor c is select * from dual@scott;
3 begin
4 open c;
5 close c;
6 commit;
7 dbms_session.close_database_link('SCOTT');
8 end;
9 /
declare
*
ERROR at line 1:
ORA-02080: database link is in use
ORA-06512: at "SYS.DBMS_SESSION", line 147
ORA-06512: at line 7

thiru@9.2.0:SQL>declare
2 cursor c is select * from dual@scott;
3 begin
4 open c;
5 close c;
6 commit;
7 end;
8 /

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>alter session close database link scott;

Session altered.

-Thiru
Previous Topic: test
Next Topic: dbca error
Goto Forum:
  


Current Time: Fri Sep 20 09:32:46 CDT 2024