Previous Topic: Rebinding the PlanNext Topic: Selecting an Alternate Plan at Runtime


Creating an Alternate Plan

To create an alternate plan, use the DEFINE AUTHORIZATION command. The format of the DEFINE AUTHORIZATION command is:

DEFINE AUTHORIZATION authid FOR PROGRAM name VERSION ver

For a complete explanation of the DEFINE AUTHORIZATION syntax, see the Command Reference Guide.

The DEFINE AUTHORIZATION command creates a new plan using the authorization ID, program name, and version specified in the command to create the new plan name. You must enter the command from the system that contains the program object. This system name is used in the new plan name.

The only thing that changes for the new plan is the authorization ID. The SQL statements are extracted from the existing program object. In the new plan, statements that reference resources defined in the program resource fill-in as QUAL=N are referenced with the authorization ID specified in the DEFINE AUTHORIZATION command. All other references in the new plan remain the same as in the original plan.

Note: The statement-IDs for each statement must match in every plan associated with the program or a runtime error occurs. This type of error can happen if the CA Datacom utility DDTRSLM exports a plan without its associated program or if a program object is transported without its associated plan.

If a plan already exists with the same name (including the authorization ID), that plan is deleted before the new plan is created. The new plan then takes the place of the old one.

If you need to change plan options for the new plan, use the ALTER PROGRAM ENVIRONMENT command to change the program object after creating the new plan. Then enter the REBIND command, specifying the authorization ID of the new plan on the REBIND command.