Previous Topic: $OPSYSTEM FunctionNext Topic: $PAD Function


$PACKAGESET Function

$PACKAGESET returns the value of the DB2 special register CURRENT PACKAGESET. The value of $PACKAGESET is stored with $PLAN. You can use the SET $PACKAGESET statement to specify a logical identifier for the next package to use. Unlike $PLAN, this is the actual package name.

This function has the following format:

$PACKAGESET

As the source of a SET statement or in a condition, $PACKAGESET returns the package name most recently set in a CA Ideal application.

As the target of a SET statement, you can use $PACKAGESET to select a package name that can instruct DB2 to change to a new package. You can set $PACKAGESET to any one‑ to eight‑character package identification or to the name of a field that contains a package identification. If $PACKAGESET is set to an alphanumeric literal, you must surround the value with double or single quotes (" or '). For example:

SET $PACKAGESET = 'PAYPKG' 

You can execute the SET $PACKAGESET statement only before the first SQL statement in a logical unit of work. That is, executing SET $PACKAGESET at any point except before the first SQL statement at the beginning of a CICS transaction or before the first SQL statement following a database Commit causes a runtime error.

The first SQL statement can be embedded SQL, SQL generated by a FOR construct for a DB2 dataview, or SQL in a non‑ideal subprogram. A Commit can be a PDL TRANSMIT, CHECKPOINT or BACKOUT statement, or an SQL COMMIT or ROLLBACK statement.

If an application calls a non‑ideal subprogram that executes SQL statements and if that SQL cam be the first in a logical unit of work, then you must specify Y (yes) for the Access DB2 field on the non‑ideal program IDE panel.

Changes made to the package name by a package name exit do not affect the value of $PACKAGESET. $PACKAGESET reflects the value set by statements in the current application.

Examples

This code selects PAYPKG as the CA Ideal application's package name for the embedded SQL that follows it.

CHECKPOINT
SET $PACKAGESET = 'PAYPKG'
EXEC SQL ...END‑EXEC
...

The following procedure saves the package name that was selected in a previous procedure in a Working Data field SAV‑PKG. It sets GETPKG as the package name to use with the FOR construct that follows it, commits its database modifications, and resets the package name before returning.

<<GET>> PROCEDURE
SET SAV‑PKG = $PACKAGESET
SET $PACKAGESET = GETPKG
FOR EACH DB2‑DVW
   ...
ENDFOR
CHECKPOINT
SET $PACKAGESET = SAV‑PKG
ENDPROC