Dynamic plan selection
It is beneficial to use dynamic plan selection and packages together. You can convert individual programs in an application that contains many programs and plans, one at a time, to use a combination of plans and packages. This process reduces the number of plans per application; having fewer plans reduces the effort that is needed to maintain the dynamic plan exit routine.
CICS®You can use packages and dynamic plan selection together, but when you dynamically switch plans, the following conditions must exist:
- All special registers, including CURRENT PACKAGESET, must contain their initial values.
- The value in the CURRENT DEGREE special register cannot have changed during the current transaction.
| Program Name | DBRM Name |
|---|---|
| MAIN | MAIN |
| PROGA | PLANA |
| PROGB | PKGB |
| PROGC | PLANC |
You could create packages using the following bind statement:
BIND PACKAGE(PKGB) MEMBER(PKGB)
EXEC CICS START TRANSID(MAIN)TRANSID(MAIN)executes program MAIN.EXEC SQL SELECT…Program MAIN issues an SQL SELECT statement. The default dynamic plan exit routine selects plan MAIN.
EXEC CICS LINK PROGRAM(PROGA)Program PROGA is invoked.
EXEC SQL SELECT…Db2 does not call the default dynamic plan exit routine, because the program does not issue a sync point. The plan is MAIN.
EXEC CICS LINK PROGRAM(PROGB)Program PROGB is invoked.
EXEC SQL SELECT…Db2 does not call the default dynamic plan exit routine, because the program does not issue a sync point. The plan is MAIN and the program uses package PKGB.
EXEC CICS SYNCPOINTDb2 calls the dynamic plan exit routine when the next SQL statement executes.
EXEC CICS LINK PROGRAM(PROGC)Program PROGC is invoked.
EXEC SQL SELECT…Db2 calls the default dynamic plan exit routine and selects PLANC.
EXEC SQL SET CURRENT SQLID = 'ABC'The CURRENT SQLID special register is assigned the value 'ABC.'
EXEC CICS SYNCPOINTDb2 does not call the dynamic plan exit routine when the next SQL statement executes because the previous statement modifies the special register CURRENT SQLID.
EXEC CICS RETURNControl returns to program PROGB.
EXEC SQL SELECT…
CICS With packages, you probably do not need dynamic plan selection and its accompanying exit routine. A package that is listed within a plan is not accessed until it is executed. However, you can use dynamic plan selection and packages together, which can reduce the number of plans in an application and the effort to maintain the dynamic plan exit routine.