Overriding the values that Db2 uses to resolve package lists

Db2 resolves package lists by searching the available collections in a particular order. To avoid this search, you can specify the values that Db2 should use for package resolution.

About this task

If you set the special register CURRENT PACKAGE PATH or CURRENT PACKAGESET, Db2 skips the check for programs that are part of a plan and uses the values in these registers for package resolution.

If you set CURRENT PACKAGE PATH, Db2 uses the value of CURRENT PACKAGE PATH as the collection name list for package resolution. For example, if CURRENT PACKAGE PATH contains the list COLL1, COLL2, COLL3, COLL4, Db2 searches for the first package that exists in the following order:
  • COLL1.PROG1.timestamp
  • COLL2.PROG1.timestamp
  • COLL3.PROG1.timestamp
  • COLL4.PROG1.timestamp

If you set CURRENT PACKAGESET and not CURRENT PACKAGE PATH, Db2 uses the value of CURRENT PACKAGESET as the collection for package resolution. For example, if CURRENT PACKAGESET contains COLL5, Db2 uses COLL5.PROG1.timestamp for the package search.

When CURRENT PACKAGE PATH is set, the server that receives the request ignores the collection that is specified by the request and instead uses the value of CURRENT PACKAGE PATH at the server to resolve the package. Specifying a collection list with the CURRENT PACKAGE PATH special register can avoid the need to issue multiple SET CURRENT PACKAGESET statements to switch collections for the package search.

The following table shows examples of the relationship between the CURRENT PACKAGE PATH special register and the CURRENT PACKAGESET special register.
Table 1. Scope of CURRENT PACKAGE PATH
Example What happens
SET CURRENT PACKAGESET
SELECT ... FROM T1 ...
The collection in PACKAGESET determines which package is invoked.
SET CURRENT PACKAGE PATH
SELECT ... FROM T1 ...
The collections in PACKAGE PATH determine which package is invoked.
SET CURRENT PACKAGESET
SET CURRENT PACKAGE PATH
SELECT ... FROM T1 ...
The collections in PACKAGE PATH determine which package is invoked.
SET CURRENT PACKAGE PATH
CONNECT TO S2 ...
SELECT ... FROM T1 ...
PACKAGE PATH at server S2 is an empty string because it has not been explicitly set. The values from the PKLIST bind option of the plan that is at the requester determine which package is invoked.1
SET CURRENT PACKAGE PATH
   = 'A,B'
CONNECT TO S2 ...
SET CURRENT PACKAGE PATH
   = 'X,Y'
SELECT ... FROM T1 ...
The collections in PACKAGE PATH that are set at server S2 determine which package is invoked.
SET CURRENT PACKAGE PATH
SELECT ... FROM 
S2.QUAL.T1 ...
Three-part table name. On implicit connection to server S2, PACKAGE PATH at server S2 is inherited from the local server. The collections in PACKAGE PATH at server S2 determine which package is invoked.
Notes:
  1. When CURRENT PACKAGE PATH is set at the requester (and not at the remote server), Db2 passes one collection at a time from the list of collections to the remote server until a package is found or until the end of the list. Each time a package is not found at the server, Db2 returns an error to the requester. The requester then sends the next collection in the list to the remote server.