You are on page 1of 11

Say What?

By Bonnie Baker

Plans + DBRMS + Packages + Collections + Versions = Confusion


No matter how long programmers have worked with DB2 for z/OS and OS/390 they still ask me to tell them the differen!e "etween a plan and a pa!kage # and what in the he!k a !olle!tion is$ % planned to write a !ol&mn on this topi! so % !o&ld '&st point them to DB2 Magazine (&arter ) 2003 and let the !ol&mn answer the *&estions$ +ell one !ol&mn "e!ame two and two morphed into three$ ,nd if they keep !hanging DB2 -as they will do. the three may one day "e!ome fo&r$

THE EARLY DAYS


/he !omple0ity and "readth of this topi! is "est &nderstood from an histori!al perspe!tive$ 1ong ago when DB2 for 23S -now OS/390 and z/OS. was in its infan!y many !ompanies had different ma!hines for development and prod&!tion$ Development often took pla!e on an older model ma!hine and the 1O,D mod&les were moved onto a "igger prod&!tion ma!hine$ %n fa!t this pro!ess still takes pla!e in some !ompanies if yo& take a "roader perspe!tive # some !ompanies develop software offsite and then r&n it in entirely different lo!ations for entirely different !orporations$ 4ome &p with a need and !ompanies will fill that need in &ne0pe!ted ways$ 4OBO1 was the lang&age of !hoi!e in the old days5 however !ompanies rarely had a 4OBO1 li!ense on the prod&!tion ma!hine$ So DB2 had to allow development on one "o0 with a 4OBO1 !ompiler "&t witho&t a DB2 s&"system and allow prod&!tion r&ns on a different "o0 with a DB2 s&"system "&t without a 4OBO1 !ompiler$ /hat6s how the !on!epts of the DB2 7re!ompiler and the data"ase re*&est mod&le -DB82. were "orn # o&t of ne!essity$ 7rogrammers !o&ld write 4OBO1 programs on the smaller non9DB2 ma!hine$ /hey !o&ld em"ed S(1 "etween the 4OBO1 S(1 delimiters -EXEC SQL and END_EXEC. in "oth the 4OBO1 working storage and pro!ed&ral divisions$ +hen they were ready to !ompile the program to look for 4OBO1 errors they6d r&n the program thro&gh the DB2 7re!ompiler to strip o&t the S(1 leaving only 4OBO1$

THE PRECOMPILER
/he DB2 7re!ompiler does not need DB2 to r&n$ %t !arries o&t three primary tasks as it reads the program serially top9to9"ottom looking for DB2 delimiters$ :irst if the delimiters s&rro&nded an INCLUDE statement the 7re!ompiler goes to the INCLUDE li"rary named in the 'o" !ontrol lang&age data definition statement and p&lls the

in!l&ded MEMBERNAME into the program$ /his function is the same as a 4OBO1 COPY MEMBERNAME "&t the timing is different$ 4OBO1 COPYBOOKs get !opied in at COMPILE time5 DB2 INCLUDEs get !opied in at pre!ompile time$ /he only differen!e "etween an S(1 INCLUDE and a 4OBO1 COPY is timing$ /he most !ommon item INCLUDEd in a program was -and is. a DCLGEN$ DCLGENs are str&!t&res that des!ri"e a ta"le$ One DCLGEN is &s&ally in!l&ded for ea!h ta"le that the program will a!!ess at r&n time$ ;a!h DCLGEN is a two9part str&!t&re !onsisting of a DECLARE TABLE statement whi!h des!ri"es the ta"le in DB2 S(1 lang&age and a 4OBO1 str&!t&re that des!ri"es the ta"le &sing an 0<91evel 4OBO1 working storage str&!t&re -m&!h like a typi!al !opy"ook for a 3S,2 file.$ Se!ond if the delimiters s&rro&nd an S(1 statement the pre!ompiler does a very "asi! synta0 !he!k to make s&re that the !ol&mn and ta"le names are valid -that they6re spelled !orre!tly and that the !ol&mns and the ta"le e0ist.$ 2any DB,s and programmers think that this validation is done "y reading the DB2 4,/,1O= "&t they6re wrong$ 8emem"er the pre!ompiler doesn6t need DB2 or its 4,/,1O=$ DB2 might not even "e installed on the ma!hine$ /he DB2 7re!ompiler &ses the top part of the D41=;N to validate the S(1 synta0$ /he third and most important task performed "y the DB2 7re!ompiler is to split the program into two parts> a 4OBO1 and a DB2 part$ ,ll of the S(1 that the programmer !aref&lly em"edded is stripped o&t of the program and p&t into its own partitioned data set -7DS. mem"er Resources !alled a DB82$ , single program !ontaining two lang&ages 4OBO1 and S(1 goes into the DB2 DB2 for z/OS and OS/390 7re!ompiler and two pie!es !ome o&t$ /wins "&t fraternal twins # m&!h like ,rnold S!hwarzenegger and Danny De3ito$ ,rnold looks '&st like his 4OBO1 mother and Danny looks '&st like his DB2 father$ 4OBO1 ,rnold with all of the S(1 !ommented o&t goes down one path in life$ S(1 Danny !ontaining only S(1 goes down a different path in life$ /he twins separated at "irth have a tenden!y to lose ea!h other$ /o help the twins find ea!h other later in life -in other words at r&n time. the pre!ompiler engraves ea!h with identi!al tattoos$ /he tattoo is !arried forward with 4OBO1 ,rnold thro&gh !ompile and link edit into the LOAD mod&le in the LOAD li"rary$ /he tattoo is part of the r&n9time e0e!&ta"le !ode of the LOAD mod&le$ /he same tattoo is !arried forward with S(1 Danny thro&gh BIND$ BIND is to S(1 what COMPILE is to 4OBO1$ /he p&rpose of 4OBO1 COMPILE is to !ome &p with r&n9time !ode for the 4OBO1$ /he p&rpose of BIND is to !ome &p with r&n9time e0e!&ta"le !ode for the S(1$ Both sets of !ode "ear identi!al tattoos -timestamps or !onsisten!y tokens.$ So the 4OBO1 twin "e!omes a transporta"le load mod&le in the 4OBO1 LOADLIB and the S(1 "e!omes a transporta"le DB82 in the DBRMLIB$ ?&st as the 4OBO1 twin had to "e !ompiled the DB82 twin has to go thro&gh BIND to !reate the r&n9time e0e!&ta"le !ode for the DB2 portion of the 4OBO1 program and p&t that e0e!&ta"le !ode into the @right@ DB2 s&"system$

ALL ABOUT BIND


!onne!ts to the DB2 in whi!h the program6s 1O,D mod&le will r&n reads the DB82 serially and then performs three tasks$
BIND

/he first of the BIND tasks is an a&thorization !he!k$ DB2 m&st make s&re that the programmer has the BIND a&thority and the S(1 a&thority to perform the re*&ested S(1 task -for e0ample &pdating the payroll master.$ +hen &sing standard a&thorization pro!ed&res DB2 won6t let yo& BIND a DB82 if yo& don6t have the a&thority to e0e!&te the S(1 that6s in the DB82$ /his is why yo& may have the a&thorization to BIND in development -a!!essing development ta"les. "&t don6t have a&thorization to BIND in prod&!tion where the S(1 a!!esses prod&!tion ta"les$ /he se!ond BIND task is a "it red&ndant$ BIND like pre!ompile m&st also !he!k the synta0 of the S(1 "&t the BIND !he!k is more sophisti!ated$ %nstead of &sing the top DECLARE TABLE portion of the DCLGEN BIND &ses the DB2 CATALOG ta"le information to make s&re that the !ol&mn names are valid that !omparisons are n&meri!9to9n&meri! and so on$ /his se!ond synta0 !he!k o!!&rs "e!a&se yo& !an6t tr&st the one done "y the pre!ompiler "e!a&se the pre!ompiler !he!k &sed the DCLGEN$ Ao& !o&ld have a DCLGEN and not have the DB2 ta"le$ /he third and most important BIND task is to !ome &p with r&n9time instr&!tions for the S(1 in the DB82$ ;a!h S(1 statement is parsed and all of the possi"le -realisti!. methods for retrieving the desired !ol&mns and rows from the ta"le are weighed meas&red and eval&ated "ased on possi"le estimated %/O 47B and SORT overhead$ , ton of information is &sed as inp&t to the BIND pro!ess not '&st CATALOG information p&t there "y r&nning the RUNSTATS &tility$ BIND inp&t in!l&des for e0ample>

%nde0es -what !ol&mns are in the inde0esC. 4ol&mns -how long is this !ol&mn and how m&!h room will it o!!&py in a SORT re!ordC. System reso&r!es -how "ig are the system reso&r!es "&ffer pool and RIDPOOLC. 7ro!essors -how "ig are they and how many engines do they haveC. DB2 -what release is r&nningC. 7arameters -what are the val&es of the BIND parametersC.

,fter all that inp&t -and more. is weighed and !ompared the !heapest most !osteffe!tive a!!ess path is !hosen and the r&ntime instr&!tions for that one path are !reated$ -%nterestingly DB2 BIND sometimes generates instr&!tions for more than one path$. /his pro!ess is !alled optimization and it6s repeated for ea!h S(1 statement in the DB82 &ntil all a!!ess paths are de!ided and the r&n9time instr&!tions are !reated for ea!h$ ,s the optimizer de!ides on ea!h path writes are done to DB2$ !he!ks to see if yo& "o&nd with the parameter EXPLAIN(YES); if so it writes do!&mentary eviden!e a"o&t the !hosen path to the PLAN_TABLE and to the DSN_STATEMNT_TABLE for yo&r edifi!ation$
BIND

also writes a lot of information to m&ltiple CATALOG ta"les do!&menting the fa!t that the BIND did o!!&r$ %n fa!t the tattooed DB82 whi!h is not &sed at r&n time is moved into the CATALOG$ O"'e!ts !hosen "y the optimizer are do!&mented in the CATALOG in !ross9referen!e ta"les$ ,nd BIND parameters are re!orded in the CATALOG also$
BIND

WHERE ARE THE INSTRUCTIONS?


%t6s interesting that the a!t&al instr&!tions for the a!!ess path are not written to the CATALOG$ Ao& !an6t look at information in the DB2 CATALOG to fig&re o&t whether a *&ery will do syn!hrono&s or asyn!hrono&s reads at r&n time$ Ao& !an6t tell if the *&ery will mat!h on three !ol&mns of an inde0 or five$ /he a!t&al r&n9time instr&!tions aren6t stored in the CATALOG$ /hey6re definitely not in the DB82 whi!h is inp&t to the BIND$ So where are they storedC /his *&estion is one of the many reasons that this !ol&mn grew into two parts$ +here in the he!k are the r&n9time instr&!tionsC Sho&ld yo& ever &se the PLAN_TABLE at r&n timeC ,re the r&n9time instr&!tions in a pa!kage a plan or a versionC ,ll of the a"oveC /he infamo&s @it depends@C +here are the instr&!tions stored while yo& wait for the 1O,D mod&le to r&nC Dow has this pro!ess !hanged over timeC +hat program preparation options are !&rrently availa"le in version EC +hat6s !oming in version FC Stay t&ned for answers to these and other *&estions$

Bonnie Baker is a !ons&ltant and ed&!ator spe!ializing in appli!ations performan!e iss&es on the DB2 OS/390 and z/OS platforms$ She is an %B2 DB2 =old 4ons&ltant a five9time winner of the %DB= Best Speaker award and a mem"er of the %DB= Speakers6 Dall of :ame$ She is "est known for her series of seminars entitled @/hings % +ish /hey6d /old 2e ;ight Aears ,go@ and the 7rogrammers Only !ol&mn in DB2 Magazine$ Ao& !an rea!h her thro&gh Bonnie Baker 4orp$ at F<39FEG90<2) or "k"akerH"onnie"aker$!om$

Say What? Part 2


By Bonnie Baker

How the separated twins - odified source code !rnold and DB" S#$ Dann% - find each other again&
%n the last iss&e of DB2 Magazine % "egan writing a"o&t the program preparation pro!ess for DB2 Bniversal Data"ase -BDB. for OS/390 and z/OS$ %f yo& haven6t read 7art < please do so now$ 7art 2 will make m&!h more sense if yo& do$ %f yo&6re still !onf&sed after reading 7arts < and 2 may"e '&st may"e ne0t *&arter6s 7art 3 will !lear &p any remaining !onf&sion and make yo& a program preparation e0pert$ By the end of 7art < we had done a PRECOMPILE to separate o&r 4OBO1 program into twins> ,rnold -that6s =overnor ,rnold now. as the modified so&r!e !ode -the S(1

!ommented o&t and DCLGENs now INCLUDEd. and Danny as the DB82 !ontaining the S(1 that &sed to "e in the so&r!e !ode$ /he 4OBO1 so&r!e !ode -witho&t any S(1. was !ompiled into r&n9time e0e!&ta"le instr&!tions for the 4OBO1 portion of the program5 DB82 Danny -all the S(1 that &sed to "e in the so&r!e mod&le. went thro&gh BIND to generate r&n9time instr&!tions for the S(1 in o&r 4OBO1 program$ % didn6t mention how ,rnold over in the 4OBO1 loadlib will find his long9lost twin # nor did % mention e0a!tly what we were "inding and where we wo&ld p&t it when we finished$ ,nd that6s what this !ol&mn is a"o&t$

The Mo i!ie Source Co e "Arno# $


,t pre!ompile time when the S(1 was stripped o&t of o&r program and moved into the DB82 -Danny. leaving only 4OBO1 in the modified so&r!e !ode yo& m&st have wondered how 4OBO1 ,rnold wo&ld ever find DB2 S(1 Danny5 in other words how the 4OBO1 wo&ld ever e0e!&te any S(1$ /he e0planation is simple$ ,ll of the e0e!&ta"le S(1 -and not all S(1 is e0e!&ta"le # a DECLARE CURSOR isn6t for e0ample. in the 4OBO1 program was repla!ed with a CALL statement -in o&r e0ample a 4OBO1 CALL.$ /he modified so&r!e !ode !omplete with its !alls to DB2 S(1 Danny was !ompiled and @linked@ into a LOAD mod&le$ +hen this LOAD mod&le is e0e!&ted and hits a paragraph that on!e !ontained S(1 -"&t now !ontains a CALL to Danny. there will "e r&n9time e0e!&ta"le !ode that knows how to link to a 4OBO19DB2 interfa!e mod&le and !onne!t to DB2 where it will find Danny and the r&n9time e0e!&ta"le !ode for the S(1 statement that previo&sly had "een in the paragraph$ 8emem"er that we tattooed the twinsC +ell this CALL !ontains the information DB2 needs to !onfirm not only that this LOAD MODULE is ,rnold -!omplete with re*&isite tattoo. "&t also that it6s the e0a!t same ,rnold that !ame o&t of the e0a!t same pre!ompile step as Danny$ /he CALL looks at the PLAN named in the e0e!&te statement of the 'o" !ontrol lang&age -?41. and sear!hes for the Danny o&t in DB2 with the same tattoo$

The DBRM "Dann%$


,t BIND time DB2 !reated r&n9time e0e!&ta"le instr&!tions for the S(1 portion of the program$ B&t where are those instr&!tions and what are they !alled now that the term DB82 no longer appliesC /he tr&th is yo& have a !hoi!e$ Ao& !an BIND the instr&!tions for the S(1 that was in the DB82 into a PLAN -the old way. or yo& !an BIND the instr&!tions into a PACKAGE -the not9so9old9"&t9no9longer9new way.$ /he reason for this !hoi!e is histori!al$ Ba!k when knights were "old dragons walked the ;arth and DB2 and some of &s were yo&ng DB82s were "o&nd dire!tly into PLANs$ %n today6s DB2 -sin!e 3283. there are two ways of doing B%NDs$ Ao& may !ontin&e to BIND DB82s into PLANs or yo& may BIND

DB82s into PACKAGEs$ +ith the se!ond option yo& keep yo&r PLAN "&t &se it only as a sear!h !hain$ /his !ol&mn e0plains why things !hanged in 3283$ , f&t&re !ol&mn will e0plain how things have !ontin&ed to !hange in v$E and v$F$ %n the early releases of DB2 the DB82 -S(1 originally em"edded in o&r 4OBO1 program "&t separated at pre!ompile time into a 7DS mem"er. was "o&nd into a PLAN -PLANA.$ /his method worked '&st fine as long as the program was a standalone program$ Ao& !oded the ?41 to e0e!&te program PGMA naming the PLAN @PLANA @ and at r&n time the twins fo&nd ea!h other$ Dowever things got a "it !ompli!ated when PGMA needed to CALL PGMB$ Be!a&se only one PLAN !o&ld "e named in an e0e!&te statement the PLAN had to !ontain r&n9time instr&!tions for "oth PGMA and PGMB$ /his pro"lem was solved "y having the BIND instr&!tion for PLANA name a mem"erlist5 the DB82s for "oth PGMA and PGMB were listed as mem"ers$ ,nd if PGMB !alled PGMC then the three wo&ld "e listed as mem"ers$ ,nd if C !alled D whi!h !o&ld !all E G or ! whi!h !o&ld !all I " K L or M whi!h !o&ld $$$$ +ell yo& get the idea$ got longer and longer$ +hat were -and still are if yo& !ling to the old te!hni*&e. the draw"a!ks of having a very long listC
M#$b#%li&'&

<$ 8emem"er that DB2 a&thorization and S(1 synta0 are !he!ked at BIND time$ ,!!ess path alternatives are also weighed the least9!ost path is !hosen -"ased on !&rrent statisti!s and system reso&r!es. and r&n9time instr&!tions are !reated for the !hosen path$ +ell if the PLAN !ontains one mem"er , this pro!ess sho&ld "e *&i!k$ B&t what if there are 20 or I0 or I00 DB82s in the mem"erlistC /he BIND !o&ld take ho&rs$ 2$ So the PLAN whi!h took more than a while to BIND !ontains I00 mem"ers$ +hat if one of the programs PGMA !hangesC +hen the so&r!e !ode !hanges the program m&st "e pre!ompiled$ ,nd pre!ompile !hanges the tattoo and !reates a new DB82$ /hat new DB82 m&st "e "o&nd into the PLAN$ +hen the PLAN is "o&nd all I00 DB82s -not '&st the modified PGMA. will "e re"o&nd$ %t !o&ld take ho&rs to BIND a PLAN even tho&gh )99 of the I00 programs haven6t !hanged$ 3$ ,lso remem"er that BIND is an opport&nity to reassess and !hange the a!!ess paths for not only the modified program "&t also every single program in the mem"erlist$ %f one program !hanges every program in the list will go thro&gh BIND$ )$ +hat if yo& want to modify PGMB to !all a new program PGM(C Ao& m&st not only pre!ompile modified B and new ( yo& also m&st add new PGM( to the mem"erlist and BIND the whole list # all I0< DB82s$ I$ Ao& want to remove PGMTC ;dit the mem"erlist and then BIND the PLAN again with the remaining I00 mem"ers in the list and wait impatiently while DB82s that haven6t !hanged go thro&gh the BIND pro!ess$ G$ Okay modified program , t&rns yo&r pro!essor over on its "a!k !asters &p$ Ao& want to fall "a!k to the original version of PGMA$ ,nd e0a!tly how wo&ld yo& do that *&i!klyC %f -and it6s a "ig if. yo& have the old DB82 with its old tattoo yo& !o&ld move it into the DB82li" and BIND the entire I009mem"er list -even tho&gh only A had regressed. and repla!e the new loadli" mem"er A with the prior

loadli" mem"er A$ Or if yo& have the old so&r!e !ode for A yo& !o&ld pre!ompile it to re!reate "oth the modified so&r!e !ode and the DB82 and then COMPILE LINK and BIND whi!h wo&ld BIND all I00 DB82s in the mem"er list$ E$ 7rogram Q has to r&n against two sets of ta"les one for 4orporation < and a se!ond for 4orporation 2$ /he sets of ta"les have identi!al names "&t different high9level *&alifiers$ Ao& !o&ld &se synonyms "&t they6re &nwieldy5 "inding d&ring a time when a synonym points to the wrong set of ta"les !o&ld !a&se disaster$ /hese -and other. *&andaries fa!ed many DB,s in the days "efore 3283 and the advent of 7,4J,=;s$

Resources
DB2 BDB for z/OS and OS/390

Packa&es an Co##ec'ions

%n 3283 the DB2 developers solved the seven pro"lems @Say +hatC@ 7art % (&arter ) % listed -and many more. "y introd&!ing another layer in 2003 the program preparation pro!ed&re$ /he pre!ompile step still split the program into tattooed twins and the treatment of the modified so&r!e !ode stayed the same$ B&t the DB82 !o&ld now "e "o&nd either into a PLAN -the old way. or into a PACKAGE$ ,ltho&gh the relationship "etween a DB82 and a PLAN was one9to9 many the relationship "etween a DB82 and a PACKAGE was always one9to9one$ 2ost of the work of BIND PLAN was moved into BIND PACKAGE$ /herefore if PGMA !hanged only PACKAGE , wo&ld have to "e "o&nd$ %f only one DB82 !o&ld "e "o&nd into a PACKAGE "&t PGMA !o&ld still CALL PGMB then a str&!t&re was needed to gather all of the PACKAGEs into a sear!ha"le list$ /his str&!t&re "e!ame a pa!kagelist rather than a mem"erlist "o&nd into a PLAN$ /his tiny !hange solved many "&t not all of the pro"lems inherent in the @mem"erlist of DB82s "o&nd into a PLAN@ te!hni*&e$ /o solve a few more pro"lems %B2 introd&!ed the !on!ept of COLLECTIONs$ , !olle!tion is simply a way of gro&ping pa!kages into meaningf&l -for yo&. gro&ps$ Ao& !o&ld BIND all of the pa!kages that m&st r&n against 4orporation <6s ta"les into one COLLECTION and all of the pa!kages that m&st r&n against 4orporation 26s ta"les into another$ Or yo& !o&ld &se COLLECTIONs to separate programs for different appli!ation areas s&!h as payroll and inventory$ ,nother &se might "e to separate programs "o&nd with ISOLATION UR from programs "o&nd with ISOLATION CS$ COLLECTIONs are simply high9level gro&ping names to designate that this gro&p of pa!kages share something anything in !ommon$ So now with the introd&!tion of COLLECTIONs o&r BIND PLAN pro!ess -think sear!h !hain. !an now in!l&de a pa!kagelist of f&lly *&alified pa!kage names s&!h as COLLPAYROLL)PGMA COLLPAYROLL)PGMB and COLLCOMMON)PGMX$ Or if we !hoose we !an '&st s&"stit&te an asterisk for the program name and list -COLLPAYROLL)* COLLCOMMON)*.$ /hen any program "o&nd into the COLLECTION will "e a!!essi"le "y the named 71,N$

Where Are Packa&es an P#ans?


+hen yo& BIND a DB82 into a PLAN or BIND a PACKAGE into a COLLECTION and then the COLLECTION-s. into a PLAN the information m&st "e stored somewhere safe inside DB2 &ntil it6s needed at r&n time$ /hese items -PLANs and PACKAGEs. aren6t stored in the DB2 4atalog$ 8ather they6re stored in the DB2 Dire!tory$ %n fa!t yo& !an think of the Dire!tory as the DB2 loadli" for the Danny portion of yo&r program !omplete with tattoo$

Run Ti(e
,t r&n time the load mod&le starts &p and event&ally hits a paragraph !ontaining a CALL to DB2$ /his CALL !ontains information s&!h as a des!ription of the tattoo the !ontent of yo&r S(1 host varia"les -now pop&lated. the statement n&m"er and so on$ /he CALL invokes the 4OBO19DB2 interfa!e program whi!h !onne!ts to DB2$ ,nd if the r&n9time !ode ne!essary to e0e!&te yo&r S(1 isn6t !&rrently resident inside DB2 -in the EDMPOOL. we go to the "&ffer pool -B70. assigned to the DB2 Dire!tory and look there$ %f we don6t find Danny there we go to 3S,2 to disk to look in the COLLECTIONs named in the PLAN for the PACKAGE with the same name and the same tattoo also known as the !onsisten!y token or timestamp$ ,nd if yo& don6t find the twin anywhere in DB2 -not that this has ever happened to anyone reading this !ol&mn. yo& get a +,-. error$ %f yo&6re still &sing the older te!hni*&e of "inding DB82s dire!tly into PLANs via a mem"erlist then an &ns&!!essf&l sear!h for Danny will res&lt in a +,/, error !ode$

Bu' Wha' A)ou' *ersions?


%n my ne0t !ol&mn %6ll give yo& some ideas a"o&t the vario&s ways of &sing the !on!ept of the COLLECTION$ %6ll also write a"o&t 3;8S%ONs and how they6re &sed$ 3ersion E introd&!ed some more &sef&l variations that will !arry &s gra!ef&lly into v$F and %6ll !over them all ne0t *&arter$

Say What? Part 3


By Bonnie Baker

'hat to do when %ou find %ourself in a (ind&


/wo !ol&mns ago % wrote a"o&t the way we &sed to do program preparation for DB2 for z/OS and OS/390$ /herefore if yo& haven6t read 7art < of this series please do so now -7rogrammers Only (&arter ) 2003.$ ,nd while yo&6re doing that yo& sho&ld also read 7art 2 -7rogrammers Only (&arter < 200).$ % promise that this !ol&mn will make m&!h more sense if yo& do$ ,nd if yo&6re still !onf&sed after reading the two prior !ol&mns and this !ol&mn let me know via email and %6ll do a 7art ) '&st for yo&$

+hen we finished 7art < we had done a PRECOMPILE to separate o&r 4OBO1 program so&r!e !ode into twins$ /win < was ,rnold -oops =overnor ,rnold now. the modified so&r!e !ode -the S(1 now !ommented o&t and D41=;Ns now INCLUDEd.$ /win 2 was Danny the DB82 !ontaining the S(1 that &sed to "e in the so&r!e !ode$ /he 4OBO1 ,rnold so&r!e !ode -with all the S(1 !ommented o&t and the e0e!&ta"le S(1 repla!ed "y a 4OBO1 CALL to DB2. was !ompiled into r&ntime e0e!&ta"le instr&!tions for the 4OBO1 portion of the program and "e!ame a load mod&le in the 4OBO1 loadlib$ DB82 Danny -all the S(1 that &sed to "e in the so&r!e mod&le. went thro&gh B%ND to generate r&ntime instr&!tions for the S(1 and "e!ame a PLAN in the DB2 Dire!tory data"ase$ By the end of 7art 2 we had learned how this program preparation pro!ess !hanged in DB2 3283$ +e learned how ,rnold over in the 4OBO1 loadlib fo&nd his long9lost twin Danny at r&ntime$ +e also fo&nd o&t a"o&t the differen!e "etween a PACKAGE and a PLAN$ ,nd we learned that PACKAGEs are stored in COLLECTIONs$ :inally we learned where these things are Resources stored when waiting for the lead program to "e r&n$ DB2 BDB for z/OS and %n this !ol&mn %6ll give yo& some ideas a"o&t the vario&s OS/390 ways of &sing the !on!ept of the COLLECTION$ %6ll also write a"o&t 0ERSIONs and how they are &sed$ DB2 v$E Say +hat 7art < introd&!ed more &sef&l variations that will !arry &s gra!ef&lly into v$F$ %6ll give yo& the high9level view$ Say +hat 7art 2

Co##ec'ion I eas
%n 7art 2 % said that a COLLECTION is simply a way of gro&ping PACKAGEs into meaningf&l -for yo&. gro&ps$ Ao& !o&ld &se COLLECTIONs to separate programs for different appli!ation areas s&!h as payroll and inventory$ ,nother &se might "e to separate programs "o&nd with ISOLATION UR from programs "o&nd with ISOLATION CS$ COLLECTIONs are simply high9level gro&ping names to designate that this gro&p of pa!kages share something anything in !ommon$
COLLECTIONs

ena"le yo& to organize yo&r PACKAGEs into like9kind gro&ps$ %n DB26s yo&nger days with m&ltiple DB82s "eing "o&nd into PLANs all the DB82s in a single PLAN had to "e "o&nd with the same BIND parameters$ Dowever today yo& !an BIND ea!h PACKAGE into a COLLECTION that has a !&stomized set of BIND parameters asso!iated with it$ ,n e0ample wo&ld "e to %SO1,/; all programs &sing 8;O7/-3,8S. in one COLLECTION and all programs &sing O7/D%N/ in another$ D;=8;;-,NA. is another BIND parameter that yo& may want to "e a "it more vigilant in monitoring$ ,n easy way of keeping an eye on programs -or !hildren. is to p&t them in a room together$ %n other words BIND parameters are m&!h more gran&lar today than they were when DB2 was yo&ng$ +ith the advent of BIND PACKAGE and the one9to9one relationship of a program to a pa!kage we were given the a"ility to name the high9level *&alifier for the ta"les a!!essed

"y the program$ /herefore the DB82 for one program !o&ld "e "o&nd into two different COLLECTIONs$ /he DB82 for program ,B4<23 !o&ld "e "o&nd into a COLLECTION !alled 1ol1o%2-/ &sing 1o%2-/ as the ta"le high9level *&alifier$ /he same DB82 !o&ld "e "o&nd into a COLLECTION !alled 1ol1o%2-3 &sing 1o%2-3 as the high9level *&alifier$ Or yo& !o&ld BIND the same DB82 into 1ol&'%#&& to r&n it against stress test ta"les and BIND it into 1ol&'%#&& to r&n against reg&lar test ta"les$ Or yo& !o&ld BIND a DB82 into a COLLECTION !alled 1ol4% to &se when yo& a!!ess read9only de!ision s&pport ta"les &sing ISOLATION UR and into a COLLECTION !alled 1ol1& when yo& &se a!tive prod&!tion data$ /here are dozens of e0amples$ ?&st &se yo&r imagination$ So at r&ntime whi!hever approa!h yo& !hose yo& now have a PACKAGE with the e0a!t same tattoo/timestamp/!onsisten!y9token in two different COLLECTIONs$ Dow do yo& tell DB2 in whi!h !olle!tion to sear!h for DannyC Normally DB2 wo&ld sear!h thro&gh all of the COLLECTIONs in the named PLAN$ B&t if yo& want to sear!h only one COLLECTION yo& simply tell DB2 in yo&r program$ Ao& !an spe!ify whi!h COLLECTION to sear!h "y &sing an S(1 statement !alled S;/ 4B88;N/ PACKAGESET$ PACKAGESET is simply a synonym for COLLECTION$ /herefore if yo& set the !&rrent PACKAGESET to 1ol1o%2-/ yo& will a!!ess 1o%2-/6s ta"les$ %f yo& set the !&rrent PACKAGESET to 1ol1o%2-3 yo& will a!!ess 1o%2-36s ta"les$ ,nd the "ea&ty of this is that yo& only have to maintain one program$

*ersions
%n 7art < % mentioned the need for rapid fall"a!k$ S&ppose program , is !hanged and moved "a!k into prod&!tion$ Before the program was !hanged it ran in <0 min&tes and never "othered anyone$ ,fter the !hange all the other programs r&nning at the same time are e0perien!ing +5// timeo&ts$ Dow do yo& fall "a!k gra!ef&lly and rapidly to the prior version of the programC ,t pre!ompile time yo& !an spe!ify a 0ERSION ID$ %f the 0ERSION ID is the same as the !&rrent version BIND will overlay the PACKAGE in its COLLECTION$ B&t if the 0ERSION ID is different from the !&rrent 0ERSION ID BINDing the DB82 will prod&!e a new PACKAGE that won6t overlay the prior PACKAGE for the program$ Ao&6ll have two PACKAGEs for the same program in the same COLLECTION$ %f yo& also move the !&rrent LOAD mod&le with its old tattoo timestamp into a different loadlib (COBOL)BACKUP) the !ompile will not overlay it$ /hen when yo& !ompile the modified so&r!e !ode yo&6ll have a LOAD mod&le with the new tattoo/timestamp in the !&rrent loadlib$ %f yo& e0e!&te the new LOAD mod&le yo&6ll find the new PACKAGE$ %f the system s&ffers yo& !an !an!el the 'o" and move the old LOAD mod&le "a!k into prod&!tion simply "y pointing to COBOL)BACKUP$

Co+ies
/here are too many other n&an!es and possi"ilities to mention5 however one feat&re that may "e &sef&l is the a"ility to !opy a pa!kage from one !olle!tion to another$ %f the

statisti!s on yo&r ta"le vary greatly from daytime to evening or "eginning of the month to end of the month yo& !an BIND a PACKAGE in a COLLECTION !alled 1olda6 or 1olb#7i8 when the statisti!s in the CATALOG are representative of yo&r daytime or "eginning of the month ta"le$ Ao& !an then COPY that PACKAGE into another COLLECTION !alled 1ol8i79' or 1ol#8d when the statisti!s in the CATALOG are representative of yo&r nighttime or end of the month ta"le$ COPY does a 8;BIND and &ses the DB82 in the CATALOG as its inp&t$ /herefore the tattoo/timestamp doesn6t !hange$ %f yo& !he!k the time of day or the day of month at the "eginning of the program yo& !an SET CURRENT PACKAGESET to the appropriate COLLECTION for DB2 to sear!h for Danny$

*ersions , an %n v$E the developers introd&!ed a new way of doing program preparation$ /he newer !ompilers -s&!h as the ;nterprise 4OBO1 33 !ompiler. let yo& skip the stand9alone PRECOMPILE$ +hyC /his new !ompiler has an appli!ation program interfa!e -,7%. to the DB2 pre!ompiler$ ,s a res&lt there is one less step in the program preparation pro!ess$ /he COMPILER is now more aware of yo&r DB2 !alls and yo&r S(1 !an take advantage of some of the host lang&age feat&res$ :or e0ample yo&r DCLGENs !an now have 4OBO1 str&!t&res that look more like 4OBO1 !opy"ooks$ /he DCLGENs on!e limited to 0< and <09level fieldnames !an now have field definitions that are more than two9levels deep$ , <09level trandate !an "e "roken into <I9level year edit!har month edit!har day$ ,lso the DCLGEN fields !an !ontain OCCURS !la&ses whi!h is m&!h more programmer friendly$ /his new !apa"ility !arries &s gra!ef&lly into the re!ently anno&n!ed DB2 v$F for z/OS$ %f yo& want to e0ploit the new m&lti9row fet!h in v$F yo& m&st fet!h yo&r rows into array str&!t&res$ +ith the new !ompiler and its ,7% DCLGENs may now have the needed arrays$

.o' i'?
:or those programmers who are '&st "eginning their work with mainframe DB2 the m&ltiple layers and possi"ilities of DB82s PLANs PACKAGEs COLLECTIONs and 0ERSIONs !an "e !onf&sing$ /he seemingly never9ending timestamp errors !an "e fr&strating$ % hope these three !ol&mns will !lear &p some of the *&estions a"o&t these DB2 entities and introd&!e possi"ilities never "efore !onsidered$

You might also like