Specifying the package collection that Db2 uses for applications
You can ensure that Db2 uses the intended package collection and does not waste time searching by explicitly specify the package collection that you want Db2 to use.
About this task
You can use the CURRENT PACKAGE PATH special register or CURRENT PACKAGESET (if CURRENT PACKAGE PATH is not set) to specify the collections that Db2 uses for package resolution. The CURRENT PACKAGESET special register contains the name of a single collection, and the CURRENT PACKAGE PATH special register contains a list of collection names.
If you do not set these special registers, they contain an empty string when your application begins to run, and they remain as an empty string. In this case, Db2 searches the available package collections.
However, explicitly specifying the intended collection by using the special registers can avoid a potentially costly search through a package list that has many qualifying entries. In addition, Db2 uses the values in these special registers for applications that do not run under a plan.
When you call an external stored procedure, the CURRENT PACKAGESET special register contains the value that you specified for the COLLID parameter when you defined the stored procedure. If the routine was defined without a value for the COLLID parameter, the value for the special register is inherited from the calling program.
If the external stored procedure is not defined with a specified COLLID value and the calling program package does not have the same collection ID as the package for the stored procedure, you might receive SQLCODE -805. In this situation, you can issue an ALTER PROCEDURE statement with the COLLID clause to fix the problem.
Also, the CURRENT PACKAGE PATH special register contains the value that you specified for the PACKAGE PATH parameter when you defined the stored procedure. When the stored procedure returns control to the calling program, Db2 restores this register to the value that it contained before the call.
Specifying the package collection for a Java routine in a JAR file that is installed in the Db2 catalog: If the Java routine definition specifies a COLLID value that is different from the collection into which the IBM® Data Server Driver for JDBC and SQLJ packages are bound, you need to run the DB2Binder utility with the -collection option to bind the driver packages into the collection that is specified by the COLLID value in the Java routine definition. If you do not do so, you might receive SQLCODE -805.