SET CURRENT PACKAGESET statement

The SET CURRENT PACKAGESET statement sets the schema name (collection identifier) that will be used to select the package to use for subsequent SQL statements.

This statement is not under transaction control.

Invocation

This statement can be embedded only in an application program. It is an executable statement that cannot be dynamically prepared. This statement is not supported in REXX.

Authorization

None required.

Syntax

Read syntax diagramSkip visual syntax diagramSETCURRENT PACKAGESET=string-constanthost-variable

Description

string-constant
A character string constant. If the value exceeds 128 bytes, only the first 128 bytes are used.
host-variable
A variable of type CHAR or VARCHAR. It cannot be set to null. If the value exceeds 128 bytes, only the first 128 bytes are used.

Notes

  • This statement allows an application to specify the schema name used when selecting a package for an executable SQL statement. The statement is processed at the client and does not flow to the application server.
  • The COLLECTION bind option can be used to create a package with a specified schema name.
  • Unlike Db2® for z/OS®, the SET CURRENT PACKAGESET statement is implemented without support for a special register called CURRENT PACKAGESET.

Examples

  • Example 1: Assume an application called TRYIT is precompiled by user ID PRODUSA, making PRODUSA the default schema name in the bind file. The application is then bound twice with different bind options. The following command line processor commands were used:
       CONNECT TO SAMPLE USER PRODUSA
       BIND TRYIT.BND DATETIME USA
       CONNECT TO SAMPLE USER PRODEUR
       BIND TRYIT.BND DATETIME EUR COLLECTION 'PRODEUR'
    This creates two packages called TRYIT. The first bind command created the package in the schema named PRODUSA. The second bind command created the package in the schema named PRODEUR based on the COLLECTION option.
  • Example 2: Assume the application TRYIT contains the following statements:
       EXEC SQL CONNECT TO SAMPLE;
       .
       .
       EXEC SQL SELECT HIREDATE INTO :HD FROM EMPLOYEE WHERE EMPNO='000010'; 1
       .
       .
       EXEC SQL SET CURRENT PACKAGESET 'PRODEUR';                            2
       .
       .
       EXEC SQL SELECT HIREDATE INTO :HD FROM EMPLOYEE WHERE EMPNO='000010'; 3
    1
    This statement will run using the PRODUSA.TRYIT package because it is the default package for the application. The date is therefore returned in USA format.
    2
    This statement sets the schema name to PRODEUR for package selection.
    3
    This statement will run using the PRODEUR.TRYIT package as a result of the SET CURRENT PACKAGESET statement. The date is therefore returned in EUR format.