Collection Ideas
said that a COLLECTION
is simply a way of grouping PACKAGE
s into meaningful (for you) groups. You could use COLLECTION
s to separate programs for different application areas, such as payroll and inventory. Another use might be to separate programs bound with ISOLATION UR
from programs bound with ISOLATION CS
. COLLECTION
s are simply high-level grouping names to designate that this group of packages share something, anything, in common.
COLLECTION
s enable you to organize your PACKAGE
s into like-kind groups. In DB2's younger days, with multiple DBRMs being bound into PLAN
s, all the DBRMs in a single PLAN
had to be bound with the same BIND
parameters. However, today you can BIND
each PACKAGE
into a COLLECTION
that has a customized set of BIND
parameters associated with it. An example would be to ISOLATE all programs using REOPT(VARS) in one COLLECTION
and all programs using OPTHINT in another. DEGREE(ANY) is another BIND
parameter that you may want to be a bit more vigilant in monitoring. An easy way of keeping an eye on programs (or children) is to put them in a room together. In other words, BIND
parameters are much more granular today than they were when DB2 was young.With the advent of
BIND
PACKAGE
and the one-to-one relationship of a program to a package, we were given the ability to name the high-level qualifier for the tables accessed by the program. Therefore, the DBRM for one program could be bound into two different COLLECTION
s. The DBRM for program ABC123 could be bound into a COLLECTION
called colcorp01
, using corp01
as the table high-level qualifier. The same DBRM could be bound into a COLLECTION
called colcorp02
, using corp02
as the high-level qualifier. Or, you could BIND
the same DBRM into colstress
to run it against stress test tables and BIND
it into colstress
to run against regular test tables. Or, you could BIND
a DBRM into a COLLECTION
called colur
to use when you access read-only decision support tables using ISOLATION UR
and into a COLLECTION
called colcs
when you use active production data. There are dozens of examples. Just use your imagination.So, at runtime, whichever approach you chose, you now have a
PACKAGE
with the exact same tattoo/timestamp/consistency-token in two different COLLECTION
s. How do you tell DB2 in which collection to search for Danny? Normally, DB2 would search through all of the COLLECTION
s in the named PLAN
. But, if you want to search only one COLLECTION
, you simply tell DB2 in your program. You can specify which COLLECTION
to search by using an SQL statement called SET CURRENT PACKAGESET
. PACKAGESET
is simply a synonym for COLLECTION
. Therefore, if you set the current PACKAGESET
to colcorp01
, you will access corp01
's tables. If you set the current PACKAGESET
to colcorp02
, you will access corp02
's tables. And the beauty of this is that you only have to maintain one program.Versions
Suppose program A is changed and moved back into production. Before the program was changed it ran in 10 minutes and never bothered anyone. After the change, all the other programs running at the same time are experiencing -911
timeouts. How do you fall back gracefully and rapidly to the prior version of the program?
At precompile time you can specify a VERSION
ID
. If the VERSION
ID
is the same as the current version, BIND
will overlay the PACKAGE
in its COLLECTION
. But, if the VERSION
ID
is different from the current VERSION
ID
, BIND
ing the DBRM will produce a new PACKAGE
that won't overlay the prior PACKAGE
for the program. You'll have two PACKAGE
s for the same program in the same COLLECTION
. If you also move the current LOAD
module with its old tattoo timestamp into a different loadlib
(COBOL.BACKUP)
, the compile will not overlay it. Then, when you compile the modified source code, you'll have a LOAD
module with the new tattoo/timestamp in the current loadlib
. If you execute the new LOAD
module, you'll find the new PACKAGE
. If the system suffers, you can cancel the job and move the old LOAD
module back into production simply by pointing to COBOL.BACKUP
.Copies
There are too many other nuances and possibilities to mention; however, one feature that may be useful is the ability to copy a package from one collection to another. If the statistics on your table vary greatly from daytime to evening or beginning of the month to end of the month, you canBIND
a PACKAGE
in a COLLECTION
called colday
or colbegin
when the statistics in the CATALOG
are representative of your daytime or beginning of the month table. You can then COPY
that PACKAGE
into another COLLECTION
called colnight
or colend
when the statistics in the CATALOG
are representative of your nighttime or end of the month table. COPY
does a REBIND
and uses the DBRM in the CATALOG
as its input. Therefore, the tattoo/timestamp doesn't change. If you check the time of day or the day of month at the beginning of the program, you can SET CURRENT PACKAGESET
to the appropriate COLLECTION
for DB2 to search for Danny.
No comments:
Post a Comment