ORA-02080: database link is in use Problem

Dear experts,

I'm running a PL/SQL procedure to insert some values to a table in another database using DBLINK. My PL/SQL procedure uses Commit and then Alter Session Close Database Link commands. However, sometimes I got  ORA-02080 errors. The database link being used is not used by any other process I know. One more thing, the database link mentioned is based on Oracle Gateway to Sybase. In other words, other database is actually "Sybase".

Could you please help me.

BR
GurcanKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
Maybe you have other links open you don't know about or some other branch of your code is reopening links.

you can query v$dblink to find db links in use.  If you have ended your transactions you can iterate though them all and close them with a block like this...  (or use execute immediate with alter session, same effect)


begin
    for l in (select db_link from v$dblink)
    loop
        dbms_session.close_database_link(l.db_link);
    end loop;
end;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdstuberCommented:
you can extend the above logic by checking the IN_TRANSACTION column and issuing a commit or rollback as needed before closing the link
GurcanKAuthor Commented:
The database user is not DBA, could it run "select db_link from v$dblink"?
sdstuberCommented:
by default, probably not.  

however I don't think there is anything public to check for open links in your own session.

request select on that view for the procedure's owner
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.