Previous Topic

Next Topic

Book Contents

Book Index

Running a DB2 Stored Procedure with Multiple Versions

Both DB2 for z/OS and DB2 for LUW can have multiple versions of Stored Procedures, though they are quite different in the way they are used.

DB2 z/OS

For DB2 z/OS, multiple versions of Stored Procedures are used to maintain a history of prior versions of a routine. This is only available for native SQL procedures.

When you run the routine, you will run the Current Active Version. If you want to go back to an earlier version of the routine, you must first run one of the following commands to change the current active version.

ALTER PROCEDURE procname ALTER ACTIVE VERSION version-id

or

SET CURRENT ROUTINE VERSION version-id

In the Run Procedure window all versions are listed. You must select the version which is the Current Active Version (in case different versions have different number of parameters).

DB2 for LUW

For DB2 for LUW, multiple versions of Stored Procedures are used when you have similar routines with a different number of parameters. This is similar to function overloading, familiar to most programmers.

When you invoke a procedure, the number of parameters you use will determine which version of the procedure is run.

In the Run Procedure window all versions are listed. When you click on a procedure you will see the number of parameters. You will be able run any version of the procedure.