PROBLEM:

While querying against a database link, got below error.

CAUSE & SOLUTION:

open_links parameter control, the number of database links each session can use without closing it.
If you access a database link in a session, then the link remains open until you close the session.

Here open_links is set to 4, i.e a session can access only 4 open database links in that session.When the open db_link connection reaches the limit(open_links), it throws ORA-02020: too many database links in use.

Solution:

1. Close the open db_link connections
2. Increase the open_links parameter (bounce required)

Let’s reproduce this error.

Now we reached maximum open database link connections.

— View the open database link connection[Need to run this from same session ]

We can see there are 4 open database link transactions and it is matching the open_links parameter( i.e 4). So quick way to fix is to close these connections.

Now we are getting an ORA-02080 error. So before closing the database link, we need to either commit/rollback.

Alternative solutions is:

Increase the open_links parameter.