Q1. Does closing a database link invalidate the package?
Not sure, but if so I suspect it'll be because of the "SELECT FROM dual@dw
", not because of the ALTER
. What happens if you hide dual@dw
behind a local view? Does the db link get created/dropped from time to time or is it created just once?
Q2. Why close a database link?
From the documentation:
Closing Database Links
If you access a
database link in a session, then the
link remains open until you close the
session. A link is open in the sense
that a process is active on each of
the remote databases accessed through
the link. This situation has the
following consequences:
If 20 users open sessions and access
the same public link in a local
database, then 20 database link
connections are open.
If 20 users open sessions and each
user accesses a private link, then 20
database link connections are open.
If one user starts a session and
accesses 20 different links, then 20
database link connections are open.
After you close a session, the links
that were active in the session are
automatically closed. You may have
occasion to close the link manually.
For example, close links when:
The network connection established by
a link is used infrequently in an
application.
The user session must be terminated.
If you want to close a link, issue the
following statement, where linkname
refers to the name of the link:
ALTER SESSION CLOSE DATABASE LINK
linkname;
Note that this statement only closes
the links that are active in your
current session.
Source: Oracle 10gR2 docs