This section describes SQL preprocessing the PACKAGE commands.
SQL statements in an application program are preprocessed (that is, analyzed and converted) by the system before the program is compiled (or assembled).
DB2 Server for VSE & VM preprocessors do the following:
The preprocessor action is shown graphically below.
![]() |
A package contains code for the SQL statements used in the program. The access path is based on available data statistics and applicable table indexes.
A package is available when its program needs it; moreover, because it is stored in a database, a package is monitored by database manager security mechanisms and change-management facilities.
You must preprocess an application program that switches between application servers on every application server that it accesses. To avoid distributing the program source code and preprocessing it on multiple systems, distribute packages to the connected (local or remote) application servers using the Database Services Utility.
To prevent you from unintentionally running an updated program against an old package, when you preprocess the package, a consistency token is generated and stored in both the program and the package. If the SQL request is to succeed when you run the program, the consistency token, which is based on a timestamp, must match the one in the package.
Each time that you preprocess a program, a consistency token is generated. You can choose to generate a blank consistency token. If you are running the program against multiple application servers, the package for that program, which is stored in all the application servers, must have the same consistency token as the program. If the consistency tokens do not match, the program cannot be run on the application server, or an error may occur. To ensure that the consistency tokens match, preprocess the program once in a DB2 Server for VSE & VM environment and distribute the package to other application servers using the UNLOAD PACKAGE command and the RELOAD PACKAGE command.
The PROGRAM command is a synonym for PACKAGE. The RELOAD or UNLOAD PROGRAM, and RELOAD or UNLOAD PACKAGE are therefore equivalent commands.
The UNLOAD PACKAGE and RELOAD PACKAGE commands are complementary: UNLOAD PACKAGE copies a package to a sequential file and RELOAD PACKAGE reads the package back into an application server.
To ensure that only authorized users manipulate packages in the database, only owners of programs and database administrators are entitled to unload or reload packages.
Keep Interconnected Databases at the Same Level |
---|
If you move a package between application servers at different release levels, and a facility of the database manager used by the reloaded package is not available on the new application server, an error occurs. The error occurs when the unloaded package is dynamically preprocessed again during the RELOAD. |
When RELOAD processing is completed, the system updates the TIMESTAMP column of the SYSACCESS catalog table to the date and time of the RELOAD.
The UNLOAD PACKAGE command generates output records that contain:
In using the UNLOAD PACKAGE command, you must be either the owner of the program whose package you are unloading or a database administrator. Supply the following information to the Database Services Utility:
Note: | The UNLOAD PACKAGE command is not supported if you are using DRDA flow. |
Your system must have database switching capability to access other application servers.
To unload a package for backup or to transfer to another application server, proceed as follows:
In VSE
UNLOAD PACKAGE (owner.package-name)
where owner is the name of the owner of the associated package, and package-name is the name of the package. If you omit owner, the database manager uses your user ID but still checks to ensure that you have the RUN privilege for the named package.
FROM (server-name)
where server-name is the name of the other application server.
OUTFILE (ddname)
where ddname identifies the sequential output file on tape. Use the same ddname in a TLBL statement. If the output file is on DASD, specify PDEV(DASD) after the ddname and use the same ddname in a DLBL statement. Do not use SYSPCH as the ddname, because the output file content may be invalid and may cause the RELOAD PACKAGE command to fail.
An example of the UNLOAD PACKAGE command is:
UNLOAD PACKAGE(MARCY.PROG3) OUTFILE(PROGOUT3) FROM(server-name)
where PROG3 is the name of the package, MARCY is the owner, PROGOUT3 is the output data file, and server-name is the name of the other application server.
In VM
UNLOAD PACKAGE (owner.package-name)
where owner is the name of the owner of the associated package, and package-name is the name of the package. If you omit owner, the system uses your user ID but still checks to ensure that you have the RUN privilege for the named package.
FROM(server-name)
where server-name is the name of the other application server.
Note: | The use of FROM always ignores any preceding CONNECT operations and uses the VM user ID as a default. In some situations, the user ID received at the target application server is different from your VM user ID. For example, an entry in the COMDIR might change the user ID, or the target system might change it. If you find this procedure unacceptable, issue the explicit CONNECTs as required, and use the UNLOAD command without the FROM parameter. |
OUTFILE(ddname)
where ddname identifies the output data file.
An example of the UNLOAD PACKAGE command is:
UNLOAD PACKAGE(MARCY.PROG3) FROM(PAYROLL) OUTFILE(PROGOUT3)
where PROG3 is the name of the package, MARCY is the owner, the package is in the PAYROLL database, and the output data file is PROGOUT3.
|For a VM application requestor, the RELOAD PACKAGE can be used |against a DB2 Server for VM application server or any non-DB2 Server for VM |application server that uses DRDA flow. For a VSE application |requestor, the RELOAD PACKAGE can be used against a DB2 Server for VSE running |on the same VSE system as the Database Services Utility, a VM Database via |Guest Sharing, or any non-DB2 Server for VSE application server that uses DRDA |flow.
The following tables show the different package migration scenarios:
Table 4. Different Reload Package Scenarios in DB2 Server for VM
Unloaded From Application Server Release | Unloaded Using DBSU Release | Reloading Using DBSU Release | Reloading To | Result | |
---|---|---|---|---|---|
Application Server Release | Using Protocol | ||||
2.2 | 2.2, 3.1 or later | 2.2, 3.1 or later | 2.2, 3.1 or later | SQLDS | No Error |
3.1 or later | 2.2, 3.1 or later | 2.2, 3.1 or later | 2.2 | SQLDS | Error |
3.1 or later | 2.2 | 2.2 | 3.1 or later | SQLDS | No Error |
3.1 or later | 2.2 | 3.1 or later | 3.1 or later | SQLDS | Error |
3.1 or later | 3.1 or later | 2.2,3.1 or later | 3.1 or later | SQLDS | No Error |
3.1 or later | 3.1 or later | 3.1 or later | 3.1 or later | SQLDS | No Error |
2.2 | 2.2,3.1 or later | 3.3 or later | 3.3 or later | DRDA | Error |
2.2 | 2.2,3.1 or later | 3.3 or later | Non DB2 for VM | DRDA | Error |
3.1 or later | 2.2 | 3.3 or later | 3.3 or later | DRDA | Error |
3.1 or later | 2.2 | 3.3 or later | Non DB2 for VM | DRDA | Error |
3.1 or later | 3.1 or later | 3.3 or later | 3.3 or later | DRDA | No Error |
3.1 or later | 3.1 or later | 3.3 or later | Non DB2 for VM | DRDA | No Error |
2.2, 3.1 or later | 2.2, 3.1 or later | 3.3 or later | 2.2, 3.1 or 3.2 | DRDA | Error |
|Table 5. Different Reload Package Scenarios in DB2 Server for VSE
Unloaded From Application Server Release | Unloaded Using DBSU Release | Reloading Using DBSU Release | Reloading To | Result | |
---|---|---|---|---|---|
Application Server Release | Using Protocol | ||||
2.2 | 2.2, 3.1 or later | 2.2, 3.1 or later | 2.2, 3.1 or later | SQLDS | No Error |
3.1 or later | 2.2, 3.1 or later | 2.2, 3.1 or later | 2.2 | SQLDS | Error |
3.1 or later | 2.2 | 2.2 | 3.1 or later | SQLDS | No Error |
3.1 or later | 2.2 | 3.1 or later | 3.1 or later | SQLDS | Error |
3.1 or later | 3.1 or later | 2.2,3.1 or later | 3.1 or later | SQLDS | No Error |
3.1 or later | 3.1 or later | 3.1 or later | 3.1 or later | SQLDS | No Error |
2.2 | 2.2,3.1 or later | 7.1 | 7.1 | DRDA | Error |
2.2 | 2.2,3.1 or later | 7.1 | Non DB2 for VSE | DRDA | Error |
3.1 or later | 2.2 | 7.1 | 7.1 | DRDA | Error |
3.1 or later | 2.2 | 7.1 | Non DB2 for VSE | DRDA | Error |
3.1 or later | 3.1 or later | 7.1 | 7.1 | DRDA | No Error |
3.1 or later | 3.1 or later | 7.1 | Non DB2 for VSE | DRDA | No Error |
2.2, 3.1 or later | 2.2, 3.1 or later | 7.1 | 7.1 | DRDA | Error |
Notes:
In using the RELOAD PACKAGE command, you must be either the owner of the program whose package you are trying to reload or a database administrator. DB2 Server for VSE & VM authorization checking grants the owner the RUN privilege after the following information is supplied to the Database Services Utility:
To reload a package ported from another application server or from backup, proceed as follows:
In VSE
RELOAD PACKAGE (ownerpackage-name)
where owner is the name of the owner of the associated package, and package-name is the name of the package. If you omit owner, the database manager uses your user ID but still checks to ensure that you have the RUN privilege for the named package.
NEW
TO (server-name)
where server-name is the name of the other application server. If the package is to be reloaded onto several application servers, leave one space, then type:
TO (application server1,application server2,application server3...)
INFILE (ddname)
where ddname identifies the sequential input file on tape. Use the same ddname in a TLBL statement. If the input file is on DASD, specify PDEV(DASD) after the ddname and use the same ddname in a DLBL statement.
An example of the RELOAD PACKAGE command is:
RELOAD PACKAGE(MARCY.PROG3) NEW INFILE(PROGOUT3) TO(server-name)
where PROG3 is the name of the package, MARCY is the owner, and server-name is the name of the other application server. The input data file PROGOUT3 is on tape.
In VM
RELOAD PACKAGE (owner.package-name)
where owner is the name of the owner of the associated package, and package-name is the name of the package. If you omit owner, the database manager uses your user ID as the owner.
NEW
TO(server-name)
where server-name is the name of the other application server. If several application servers are to be reloaded, leave one space; then type:
TO(application server1,application server2,application server3...)
Notes:
INFILE(ddname)
where ddname identifies the input data file.
An example of the RELOAD PACKAGE command is:
RELOAD PACKAGE(MARCY.PROG3) NEW TO(HOLIDAY) INFILE(PROGOUT3)
where PROG3 is the name of the package, and MARCY is the owner. The package is created in the HOLIDAY database and the input data file is PROGOUT3.
Your system must have the capability to switch to other application servers.
To reload a package into an application server where a package with the same name already exists, proceed as in Reloading a Package into an Application Server in Which Its Application Does Not Exist, but type:
REPLACE
or
REPLACE REVOKE
where REPLACE indicates that the existing package is to be replaced by the input package with previous user privileges intact, and REPLACE REVOKE indicates that the existing package is to be replaced by the input package with previous user privileges revoked. An example of the RELOAD PACKAGE command is:
RELOAD PACKAGE(MARCY.PROG3) REPLACE REVOKE TO(PAYROLL) INFILE(PROGOUT3)
where PROG3 is the name of the package, and MARCY is the owner. The package exists in the PAYROLL database; therefore, you use REPLACE to replace it and REVOKE to revoke user privileges on the package. The input data file is PROGOUT3.