MainframeSupports
tip week 24/2004:

Since versioning of packages was introduced in DB2 there has been an ongoing debate of pro's and con's of this feature. The advantage is undoubtfully that you can introduce new versions of a package without any downtime at all. The problem is that you must remember to clean up old versions, otherwise you risk to have old versions of programs running, where they without versioning would have failed with timestamp error (SQL-code -805).

Clean up of old versions can be hard to acheive so some kind of solution in between will be really good. The following idea I got from Bonnie Baker, one of the famous DB2 guru's. Instead of versioning you can use two collections, the current collection and a fallback collection. When fallback no longer is required you simply remove the obsolete packages by FREE'ing them from the fallback collection.

The concept is implemented in the following three steps:

  1. BIND of plans is made with a package list containing both the current and the fallback collection. Here is an example including only one package in the plan.

    BIND PLAN(MYPLAN) OWNER(ME) VALIDATE(RUN) +
         PKLIST(MYCOLL.MYPACK, FALLBACK.MYPACK)

    It is essential to use VALIDATE(RUN) because most of the time packages in the FALLBACK collection will be unavailable.

  2. When a new version of MYPACK is about to be bound, you must carry out the following two BIND operations:

    BIND PACKAGE(FALLBACK) OWNER(ME) COPY(MYCOLL.MYPACK)
    BIND PACKAGE(MYCOLL) OWNER(ME) MEMBER(MYPACK)

    Here you must be careful with the order of the BIND operations. The smart part is the COPY operation that copies the current package to the FALLBACK collection. After the execution of these two BIND operations, MYPLAN is able to execute both the old and the new version of program MYPACK.

  3. When you no longer need the fallback package you just FREE package MYPACK in collection FALLBACK. In a production environment you can schedule a clean up job to run some time after the migrations.

If you already are using generic packages (MYCOLL.*) it is very simple to implement this versioning concept, while it is a more time consuming effort if you still want to explicitly name all packages in the package list. With explicit naming you have to repeat every package in the fallback collection. You may use a generic specification for the fallback collection together with explicit naming in the current package list. Then you must remember to put the fallback collection last in the package list in order to acheive the best performance results.

Previous tip in english        Sidste danske tip        Tip list