You are on page 1of 26

Reviewer: - What is a DB2 Utility and what are the different kinds?

Allow you to control the operation of DB2 utility progra s! which run separately fro the DB2 processor" Using the task panel! you can create and su# it a utility $o#! create and edit a utility $o#! display the %&A&U% of or %&'( a utility" )*+), DA&A )*+), -.D+/ )*+), 1'B )'(2 D-A4.'%+ 1'AD 5+R4+)'(2 5'D-62 7U-+%)+ R+BU-1D -.D+/ R+)'8+R R+'R4 -.D+/ R+'R4 &AB1+%(A)+ R+(A-R R+('R& %&'%(A)+ U.1'AD -ndicates which rows in the ta#le space are to #e checked for referential constraints" &ests whether inde0es are consistent with the data they inde0! and issues a warning essage if it finds an error" -dentifies any structural defects in a 1'B ta#le space and any invalid 1'B values" )opies data fro a ta#le space to a se3uential data set" -t can #e used to copy the entire space or only the data that changed since the last copy was ade" 4enerates infor ation useful in diagnosing pro#le s" 1oads data fro a se3uential data set to DB2 ta#les" 5erges several partial copies of a ta#le space into one copy and erges partial copies with a full i age copy to ake a new full i age copy" Deletes a row fro the %2%-B5"%2%)'(2 catalog ta#le and the %2%-B5"%2%14R.4 directory ta#le" +sta#lishes a point of recovery for a ta#le space! partition! ta#le space set or a list of ta#le spaces and ta#le space sets" Reconstructs inde0es fro the ta#le they reference"

Recovers data to the current state or to a previous point in ti e #y restoring to an i age copy! then applying log records" Reorgani9es inde0es : unloads data in the for at accepta#le to the 1'AD utility" Reorgani9es ta#le spaces : unloads data in the for at accepta#le to the 1'AD utility" Allows you to change specific values within a DB2 data#ase without using %71" Reports ta#le space infor ation! including recovery history fro %2%-B5"%2%)'(2 catalog ta#le! log ranges fro %2%-B5"%2%14R.4! volu e serial nu #ers where archive log datasets reside! and na e of all ta#le spaces in a ta#le space set" 4athers su ary infor ation a#out the characteristics of data in ta#le spaces and inde0es" Updates DB2 catalog colu ns that indicate how uch space is allocated for storage groups and related ta#le spaces and inde0es" Unloads data fro one or ore ta#le spaces or i age copy data sets to one or ore se3uential datasets in an e0ternal for at"

RU.%&A&%

+0plain different utilities used:

1'AD ; is used to load one or ore ta#les of a ta#le space" -t loads records into the ta#les and #uilds or e0tends any inde0es defined on the " -f the ta#le space already contains data! you can choose whether you want to add the new data to the e0isting data <1'AD R+%U5+= or replace the e0isting data <1'AD R+(1A)+=" &he loaded data is processed #y any edit or validation routine associated with the ta#le! and any field procedure associated with any colu n of the ta#le RU.%&A&% - &he RU.%&A&% online utility gathers su ary infor ation a#out the characteristics of data in ta#le spaces! inde0es! and partitions" DB2 records this infor ation in the DB2 catalog and uses it to select access paths to data during the #ind process" -t is availa#le to the data#ase ad inistrator for evaluating data#ase design and to aid in deter ining when ta#le spaces or inde0es ust #e reorgani9ed" &here are two for ats for the RU.%&A&% utility: RU.%&A&% &AB1+%(A)+ and RU.%&A&% -.D+/" RU.%&A&% &AB1+%(A)+ gathers statistics on a ta#le space and! optionally! on inde0es or colu ns> RU.%&A&% -.D+/ gathers statistics only on inde0es" &o update the catalog statistics! run the RU.%&A&% utility after a 1'AD or R+BU-1D -.D+/ $o#" R+(A-R - &he R+(A-R online utility repairs data" &he data can #e your own data! or data you would not nor ally access! such as space ap pages and inde0 entries" -t can #e used to: o Reset a pending status on a ta#le space or inde0 o 8erify the contents of data areas in ta#le spaces and inde0es o Replace the contents of data areas in ta#le spaces and inde0es o Delete a single row fro a ta#le space o (roduce a he0adeci al du p of an area in a ta#le space or inde0 o Delete an entire 1'B fro a 1'B ta#le space o Du p 1'B pages 7U-+%)+ - &he 7U-+%)+ online utility esta#lishes a 3uiesce point <the current log RBA or log record se3uence nu #er <1R%.== for a ta#le space! partition! ta#le space set! or list of ta#le spaces and ta#le space sets! and records it in the %2%-B5"%2%)'(2 catalog ta#le" A successful 7U-+%)+ i proves the pro#a#ility of a successful R+)'8+R or )'(2" 2ou should run 7U-+%)+ fre3uently #etween regular e0ecutions of )'(2 to esta#lish regular recovery points for future point in ti e recovery

After loading a ta#le! what other steps needs to #e done? 2ou need to run RU.%&A&%" RU.%&A&% update the DB2 catalog of the ta#le" -t provides statistics on the ta#le for use for opti i9ation during #ind

When loading the ta#le! what will happen to the current records in the ta#le? -t depends on the 1'AD para eter you will use" -f you use 1'AD R+%U5+! the records loaded will #e appended to the e0isting records" -f you use 1'AD R+(1A)+! the records loaded will overlay the records"

What is +/(1A-.? +/(1A-. is used as a B-.D option ?+/(1A-. <2+%=@ )an #e invoked #y e0ecuting the %71 +/(1A-. state ent either statically or dyna ically <756 or %(U6-="

+/(1A-. is a onitoring tool that o#tains infor ation a#out the access paths for all e0plaina#le %71 state ents in a package or the DBR5s of a plan <the infor ation appears in ta#le (1A.A&AB1+=> o#tains infor ation on esti ated cost of e0ecuting an %71 %+1+)&! -.%+R&! U(DA&+ or D+1+&+ state ent <the infor ation appears in ta#le D%.A%&A&+5+.&A&AB1+=> o#tains infor ation on User-defined functions referred to in a %71 state ent! which includes the specific na e and sche a <the infor ation appears in ta#le D%.A6U.)&-'.A&AB1+=" -nfor ation gathered #y +/(1A-. can #e of help for designing data#ases! inde0es! and application progra s" &his infor ation can also tell when to re#ind an application or can #e of help in deter ining the access path chosen for a 3uery"

What do you need to do #efore you do +/(1A-.? 5ake sure that the (1A.A&AB1+ is created under the AU&*-D"

Where is the output of +/(1A-. stored? -n U%+R-D"(1A.A&AB1+" ean?

+/(1A-. has output with 5A&)*)'1% B C" What does it A non atching inde0 scan if A))+%%&2(+ B -"

What is %(U6-? %(U6- is short for %71 (rocessor Using 6ile -nput" %(U6- processes %71 state ents that are not e #edded in a progra " -t is especially useful for granting an authori9ation or creating a ta#le when a host language is not necessary and for testing state ents that are to #e e #edded in a progra later" 2ou ay na e a new e #er of a previously allocated li#rary" Using the -%(6D(D6 editor! you ay enter one or ore %71 state ents to #e processed" +ach state ent ust end with a se icolon" 'ther choices on the task panel allow you to process the state ent<s=! auto atically co it <or not= any changes to the data#ase! and #rowse the output"

What is 756? 756 is short for 7uery 5anage ent 6acility" 7uery 5anage ent 6acility is an interactive 3uery product that allows you to create reports and charts fro relational data under 58%D/A and 58%D+%A" With 756! you can: o Access data kept in DB2 ta#les o (erfor calculations on that data o -nsert new data and change or delete e0isting data o (roduce and print custo i9ed reports for your data o )reate and for at charts o )o unicate with other products

What are the different DB2 %71)'D+% you have encountered? EFCC - .o row et the search conditions specified in an U(DA&+ or D+1+&+ state ent> &he result of a %+1+)& -.&' state ent was an e pty ta#le> A

6+&)* state ent was e0ecuted when the cursor was positioned after the last row of the result ta#le> &he result of the su#select of an -.%+R& state ent is e pty" EC - found condition D no error condition -GCH - +0ecution of the re3uested -.%+R& or U(DA&+ would result in duplicate values occurring on the uni3ue inde0" &he update ight also #e caused #y a D+1+&+ operation of a parent row that cascades to a dependent row with a delete rule of %+& .U11" -GFF - +0ecution of an e #edded %+1+)& state ent or a su#select in the %+& clause of an U(DA&+ state ent has resulted in a result ta#le that contains ore than one row" Alternatively! a su#3uery contained in a #asic predicate has produced ore than one value" -GFG - &he preco piler-generated ti esta p in the load odule is different fro the #ind ti esta p in the DBR5" -GCI - An application progra atte pted to use a DBR5 or package that was not found on the plan" -JFF - &he current unit of work was the victi in a deadlock! or e0perienced a ti eout! and had to #e rolled #ack -JCK ; Unsuccessful e0ecution caused #y unavaila#le resource"

*ow would you correct an %71)'D+ of ;GCH? 5ake sure that a uni3ue inde0 is used )hange the error handling logic inside the application <e"g" -f %71)'D+B -GCH &hen +0ec %71 UpdateL= -n the application! do a %+1+)& prior to -.%+R& or U(DA&+" -f row is found! do an U(DA&+" 'therwise! do an -.%+R&"

*ow would you handle an %71)'D+ of ;GFF? Although not advisa#le! the easiest way of eli inating a ;GFF is #y using the D-%&-.)& clause on the %+1+)& state ent <e"g" +0ec %71 %elect D-%&-.)&L= )heck if the W*+R+ clause used on the %+1+)& co prises the uni3ue inde0 of the ta#le" -f not uni3ue! either A1&+R the inde0 of the ta#le or change the W*+R+ clause on the application such that it uses all colu ns of the uni3ue inde0" -f ultiple rows is really e0pected! Utili9e a )UR%'R

What are the different logical steps in e ploying a cursor? D+)1AR+ )UR%'R '(+. (erfor a 6+&)* routine until %71)'D+ is EFCC )1'%+ )UR%'R

When will you use %+1+)& or )UR%'R? -f the 3uery returns only one row! use %+1+)&" &o ensure one row is returned! W*+R+ clause should #e using the uni3ue inde0 colu ns" When the 3uery returns ultiple rows and you want to process each row! use a )UR%'R! if you $ust want to check if at least one row e0ists! use %+1+)& with a clause of 6+&)* 6-R%& F R'W '.12 or using D-%&-.)& function"

What will happen if - issue a )'55-& on a )UR%'R? )UR%'R will #e close when )'55-& is issued" )UR%'R will .'& #e closed is the )UR%'R has a W-&* *'1D option"

What would you do if you encountered an %71)'D+ EFCC on '(+. cursor? &here is no %71)'D+ EFCC on '(+. cursor

What is %71)'D+ ;IC2? Would the application a#end if not handled? +rror is raised #y DB2 when an '(+. cursor is e0ecuted to an already open cursor .o data changes! the application does not a#end

What is an %71)'D+ ;ICF? Would the application AB+.D if not handled? %71)'D+ is raised when a )1'%+ cursor is e0ecuted on a cursor that is not open .o data changes! the application does not AB+.D"

What causes an %71)'D+ ;GFG? *ow would you handleDcorrect an %71)'D+ ;GFG? &he %71 pre-co piler places ti esta p in the DBR5 and in the load odule of the application progra " At run-ti e! the two ti esta ps are co pared with each other" -f the two ti esta ps do not atch! the DBR5 and the load odule were not the result of the sa e pre-co pile" An ;GFG condition is then raised" Reco pile and #ind the progra

What are the different causes of an %71)'D+ ;GCI? *ow would you handleDcorrect this error? &he DBR5 na e was not found in the e #er list of the plan and there is no package list for the plan" &he package na e was not found #ecause there is no package list for the plan" &he Mlocation-na eM in the package list was not correct when the application was #ound" &he application was not connected to the proper location" Re#ind would correct the error -f due to wrong Nlocation na eO or connected to the wrong location! ake sure that the application connects to the right location at runti e"

What is deadlock <give a scenario=? What can you do with an %71)'D+ ;JFF? (R'4RA5 A has R'W 2 locked and (R'4RA5 B has R'W / locked" 1ater on! (R'4RA5 A re3uests for R'W / and was suspended since (R'4RA5 B currently locks the row" &hen (R'4RA5 B re3uest for R'W 2 and was suspended since (R'4RA5 A currently locks the row" At this point! (R'4RA5 A and (R'4RA5 B are in D+AD1')," DB2 would then try to roll#ack changes ade #y #oth progra s" -f the roll#ack is successful! an %71)'D+ ;JFF is raised" 'therwise! an %71)'D+ ;JFH is raised" Rerun the progra and hope that the scenario a#ove is not repeated"

Use the W-&* UR clause on the %+1+)& state ents on #oth progra s for ini al row locking"

What causes an %71)'D+ ;JCK? *ow do you fi0 it? Unsuccessful e0ecution caused #y unavaila#le resource" %o e#ody ust have loaded the ta#le and is still in the error status" (ossi#le error status are )*+), (+.D-.4! R+)'8+R (+.D-.4! )'(2 (+.D-.4" 'ther possi#ility is the 1'AD $o# is still running" &a#lespace or inde0 is in %&'( status" &here could #e several reasons for this! #ut usually it is one of three: F" An i age copy needs to #e taken" DB2 turns the copy pending flag on if the DB2 load utility has #een run with the para eter Plog noP" %ince Plog noP does not log transactions to the syste log! DB2 re3uires an i age copy #e perfor ed" &his gives DB2 a starting place in case recovery needs to #e run at so e later ti e" -f an i age copy was not taken! the rows inserted with the load utility <with Plog noP= would #e lost" 2" )ontention with another progra " DB2 allows concurrency" &his eans ore than one process can update a ta#le at the sa e ti e" But long running update progra s can change this" -f an update progra is started! every ti e an update happens a lock is placed on the )- <or row if row level locking is #eing used=" DB2 only has a certain a ount of locks" 'nce this a0i u threshold of locks is used! DB2 escalates to a ta#lespace lock" &his eans only the process that caused the escalation can use the ta#le" All other processes will receive a -JCK" H" A DB2 utility is #eing e0ecuted" )ertain DB2 utilities re3uire e0clusive control of the ta#le" -f a process is started while one of these is e0ecuting! a -JCK is issued"

What is the difference #etween B-.D! R+B-.D and 6R++? 5odifies the relationship #etween the DB2 planDpackage and the associated application" o o o

Bind - +sta#lishes or replaces an application planDpackage" Re#ind - 5odifies an e0isting application planDpackage" 6ree - Deletes an application planDpackage"

BIND <not to #e confused with REBIND= uses as input the %71DDBR5 in the DBR5 1i#rary" &he assu ption with BIND is that the progra source code has #een changed and that a new DBR5 e0ists" R+B-.D uses the current copy of the DBR5 in the DB2 )atalog" &he assu ption is that the progra has not changed #ut that so ething e0ternal to the progra has" R+B-.Ds are nor al for situations where inde0es are added or dropped or RU.%&A&% has #een run and the statistics have changed significantly" (ro#a#ly the ost dra atic e0ternal change is the installation of a new version of DB2

What does B-.D do?

)heck authori9ations )heck DB2 access paths )reates the ost effective path

When do you need to R+B-.D? &a#le change DB2 upgrade

What is a plan? When will it #e created? A (1A. is a control structure that is used to e0ecute %71 state ents" &he control structures can #e thought of as the #ound or operational for of %71 state ents taken fro a database request module (DBRM). -t can also contain a list of package na es" -t relates an application process to a local instance of DB2! specifying the processing options" &he control structure that is contained inside a plan is generated when a B-.D (1A. or a B-.D (A),A4+ is e0ecuted" &hus! a (1A. is created after the successful e0ecution of a DB2 B-.D su#co and"

What is )'55-& and R'11BA),? Both operations ends a unit of work )'55-& is an operation that ends a unit of work #y releasing locks so that the data#ase changes that are ade #y that unit of work can #e perceived #y other processes R'11BA), is the process of restoring data changed #y %71 state ents to the state at its last co it point" All locks are freed"

'n a #atch progra that writes a record to a file and at the sa e ti e updates a DB2 ta#le! what will happen when a DB2 error occurs? What will happen to the records written into the se3uential file? &he DB2 updates are rolled #ack #ut the se3uential file inserts stays"

)an we use +/+) %71 )'55-& or +/+) %71 R'11BA), on a )-)%DDB2 application?

2ou ust not use +/+) %71 )'55-& or +/+) %71 R'11BA), co ands in a )-)% application" %ince )-)% is the coordinator of the two phase co it process! you ust use +/+) )-)% %2.)('-.& or +/+) )-)% %2.)('-.& R'11BA), co ands instead"

'n a )-)% progra that updates a 8%A5 file and at the sa e ti e updates a DB2 ta#le! what will happen when a DB2 error occurs? What will happen to the records inserted into the 8%A5 file? &he DB2 updates and 8%A5 updates are roll#acked" -ssue +/+) )-)% %2.)('-.& to co it #oth records" +0ec )-)% %yncpoint co and is called a two phase )o it #ecause )-)% will first co it changes to the resources under its control like 8%A5 files! #efore DB2 changes are co itted" Usually )-)% signals DB2 to co plete the ne0t phase and release all the locks"

What is the #asic difference #etween a Q'-. and a U.-'.? A $oin selects colu ns fro 2 or ore ta#les" A union selects rows fro 2 or ore 3ueries"

What is the difference #etween U.-'. and U.-'. A11? A U.-'. does not return duplicates" A U.-'. A11 returns duplicates"

When you do U.-'.! are the results ordered? .o! it is not ordered"

What are the different types of Q'-.%? -nner Qoin: co #ine infor ation fro two or ore ta#les #y co paring all values that eet the search criteria in the designated colu n or colu ns of one ta#le with all the values in corresponding colu ns of the other ta#le or ta#les" &his kind of $oin which involve a atch in #oth colu ns are called inner $oins" 'uter $oin : -s one in which you want #oth atching and non atching rows to #e returned" DB2R Data#ase has no specific operator for outer $oins! it can #e si ulated #y co #ining a $oin and a correlated su# 3uery with a U.-'."

What is )'A1+%)+? What is 8A1U+? &he )'A1+%)+ function returns the value of the first no null e0pression" &he argu ents are evaluated in the order in which they are specified! and the result of the function is the first argu ent that is not null" &he result can #e null only if all argu ents can #e null" &he result is null only if all argu ents are null" 8A1U+ can #e specified as a synony for )'A1+%)+" +0a ple: &his e0a ple selects title and price for all #ooks" -f the price for a given title is .U11! the price shown is C"CC" %+1+)& title! )'A1+%)+<price! C"CC= A% price 6R'5 titles>

What are null indicators? and what are the possi#le values in the varia#le and what do they ean? A .U11 -.D-)A&'R is an indicator varia#le that could #e used to deter ine: o whether the value of an associated output host varia#le is null or indicate that an input host varia#le value is null" 8alue B -F" o the original length of a character string that was truncated during assign ent to a host varia#le" 8alue B En" Where n is the original length of the field" o &he value returned is not null" 8alue B C" .ull indicators are defined as #inary! (-) %J<K= )'5(" +0a ple: &his e0a ple selects title and author for all #ooks and the author for a given title is .U11AB1+" Ws-author-null-indicator is the null varia#le"

%+1+)& title! author -.&' :ws-title !:ws-author:ws-author-null-ind 6R'5 titles> What will happen if you forgot .U11 indicator is issing?

-f a null indicator is not used! an %71)'D+ -HCI is returned"

What %71)'D+ will you get if you have a .U11 -.D-)A&'R coded? -t will always #e 9eroes"

-n the sa ple 3uery #elow! if A))'U.& is .U11! will it #e returned? %+1+)& A))'U.& 6R'5 &AB1+AF W*+R+ A))'U.& S NCCCCCCCCO .o! it will not #e returned" 2ou should add addition criteria in the W*+R+ clause of 'R A))'U.& -% .U11%"

What is 4&&? 4&& is short for 4lo#al &e porary &a#le" -t is use store i ediate %71 results when you donOt want to store it in a per anent ta#le" &wo types of 4&& are )reated &e porary &a#le and Declared &e porary &a#le" )reated &e porary &a#les A created te porary ta#le e0ists only as long as the process that uses it" &e porary ta#les are created using the )R+A&+ 41'BA1 &+5('RAR2 &AB1+ state ent" When created! the sche a for the ta#le is stored in the DB2 syste catalog <%2%-B5"%2%&AB1+%= $ust like any other ta#le! #ut the &2(+ colu n is set to M4M to indicate a glo#al te porary ta#le" )reated te porary ta#les are so eti es referred to as glo#al te porary ta#les ; #ut this is confusing since declared te porary ta#les are also referred to as glo#al declared ta#les" -t is i portant to re e #er that a created glo#al te porary ta#le ust #e created using a DD1 )R+A&+ state ent #efore it can #e used in any progra " A created te porary ta#le is instantiated when it is referenced in an '(+.! %+1+)& -.&'! -.%+R&! or D+1+&+ state ent! not when it is created" +ach application process that uses the te porary ta#le creates a new instance of the ta#le for its use" When using a created te porary ta#le! keep the following in ind: o o Because they are not persistent! so e typical data#ase operations including locking! logging! and recovery do not apply to created te porary ta#les" -nde0es can not #e created on created te porary ta#les so all access is #y a co plete ta#le scan" )onstraints can not #e created on created te porary ta#les"

A null is the only default value per itted for colu ns of a created te porary ta#le" )reated te porary ta#les can not #e referenced #y DB2 utilities" )reated te porary ta#les can not #e specified as the o#$ect of an U(DA&+ state ent" When deleting fro a created te porary ta#le! all rows ust #e deleted"

o o

o o

Although views can #e created on created te porary ta#les! the W-&* )*+), '(&-'. can not #e specified"

Work file data sets are used to anage the data of created te porary ta#les" &he work data#ase <D%.DBCT= is used as storage for processing %71 state ents that re3uire working storage ; not $ust for created te porary ta#les" %o if you are using created te porary ta#les #e sure to e0a ine the DB2 -nstallation 4uide for tactics to esti ate the disk storage re3uired for te porary work files" When a te porary work file result ta#le is populated using an -.%+R& state ent! it uses work file space" .o other process can use the sa e work file space as that te porary work file ta#le until the ta#le goes away" &he space is reclai ed when the application process co its or rolls #ack! or when it is deallocated! depending which R+1+A%+ option was used when the plan or package was #ound" -t is a good idea to keep the work files in a separate #uffer pool to ake it easier to onitor" -6)-D CHFF in perfor ance trace class G can #e used to distinguish these ta#les fro other uses of the work file" Declared &e porary &a#les With 8ersion T of DB2! -B5 introduced declared te porary ta#les" Actually! to #e ore accurate! declared te porary ta#les were ade availa#le in the inter ediate DB2 8ersion U refresh" &his new type of te porary ta#le is different than a created te porary ta#le and overco es any of their li itations" &he first significant difference #etween declared and created te porary ta#les is that declared te porary ta#les are specified using a D+)1AR+ state ent in an application progra ; and not using a DD1 )R+A&+ state ent" Because they are not persistent they do not have descriptions in the DB2 )atalog" Additionally! declared te porary ta#les offer significant features and functionality not provided #y created te porary ta#les" )onsider: o o Declared te porary ta#les can have inde0es and )*+), constraints defined on the " 2ou can issue U(DA&+ state ents and positioned D+1+&+ state ents against a declared te porary ta#le" 2ou can i plicitly define the colu ns of a declared te porary ta#le and use the result ta#le fro a %+1+)&"

%o declared te porary ta#les are uch ore functional than created te porary ta#les" &o VcreateW an instance of a declared te porary ta#le you ust issue the D+)1AR+ 41'BA1 &+5('RAR2 &AB1+ state ent inside of an application progra " &hat instance of the declared te porary ta#le is known only to the process that issues the D+)1AR+ state ent" 5ultiple concurrent progra s can #e e0ecuting using the sa e declared te porary ta#le na e #ecause each progra will have its own copy of the te porary ta#le" But there is ore work re3uired to use a declared te porary ta#le than there is to use a created te porary ta#le" Before you can declare te porary ta#les you ust create a te porary data#ase and ta#le spaces for the to use" &his is acco plished #y specifying the A% &+5( clause on a )R+A&+ DA&ABA%+ state ent" &hen! you ust create seg ented ta#le spaces in the te porary data#ase" 'nly one te porary data#ase for declared te porary ta#les is per itted per DB2 su#syste " When a D+)1AR+ 41'BA1 &+5('RAR2 &AB1+ state ent is issued! DB2 will create an e pty instance of the te porary ta#le in the te porary ta#le space" -.%+R& state ents are used to populate the te porary ta#le" 'nce inserted! the data can #e accessed! odified! or deleted" When the progra co pletes! DB2 will drop the instance of the te porary ta#le" Also! #e aware that users of te porary ta#les ust have #een granted U%+ authority on the te porary ta#le space" What is the difference #etween )*AR and 8AR)*AR? &he char is a fi0ed-length character data type! the varchar is a varia#le-length character data type" Because char is a fi0ed-length data type! the storage si9e of the char value is e3ual to the a0i u si9e for this colu n" Because varchar is a varia#le-length data type! the storage si9e of the varchar value is the actual length of the data entered! not the a0i u si9e for this colu n" 2ou can use char when the data entries in a colu n are e0pected to #e the sa e si9e" 5a0i u length of 2IK" 2ou can use varchar when the data entries in a colu n are e0pected to vary considera#ly in si9e" 5a0i u length is H2!UT2"

*ow do you define the different DB2 data-types? %5A11-.& or B-.AR2 -.&+4+R D+)-5A1< !n= )*AR<n= 8AR)*AR<n= DA&+ &-5+ &-5+%&A5( (-) %J<K= )'5(" (-) %J<J= )'5(" (-) %J< =vJ<n= )'5(-H" (-) /<n= CF 8AR)*AR KJ 1+.4&* (-) %J<K= )'5(" KJ &+/& (-) /<n=" (-) /<FC=" (-) /<G=" (-) /<2U="

What are %)A1AR and )'1U5. functions?

)olu n functions are an operation that derives its result #y using values fro one or ore rows and produces a single value" +0a ple: A84 )'U.& 5A/ 5-. %U5 D-%&-.)&

%calar functions return values to each row" +0a ple: )*AR )'A1+%)+ DA&+ DA2 DA2% D+)-5A1 D-4-&% 61'A& *+/ *'UR -.&+4+R 1+.4&* 5-)R'%+)'.D 5-.U&+ 5'.&* %+)'.D %UB%&R &-5+ &-5+%&A5( 8A1U+ 8AR4RA(*-) 2+AR

What is %UB%&R function? &he %UB%&R function returns a su#string of a string" %UB%&R is used for string anipulation with colu n na e! first position and string length used as argu ents" +g" %UB%&R <.A5+! F H= refers to the first three characters in the colu n .A5+" +0a ple: %+1+)& X 6R'5 (R'Q+)&% W*+R+ %UB%&R<(R'Q.A5+!F!FC= B M)'.8+R%-'.M>

Will -.D+/ #e use if we use the function %UB%&R? 2es" eans?

What does 4R'U( B2

&he 4R'U( B2 clause specifies a result ta#le that consists of a grouping of the rows eans?

What does *A8-.4

&he *A8-.4 clause filters results o#tained #y the 4R'U( B2 clause" +0a ple: %+1+)& D+(&! A84<%A1AR2= 6R'5 7"%&A66 4R'U( B2 D+(& *A8-.4 )'U.&<X= Y K

What is the difference #etween -. and B+&W++.? &he B+&W++. predicate deter ines whether a given value lies #etween two other given values specified in ascending order" &he given value will #e inclusive to the two other given values" &he -. predicate co pares a value or values with a set of values"

What is 1-,+ and how is it #eing used? &he 1-,+ predicate searches for strings that have a certain pattern" &he underscore character <A= represents any single character" &he percent sign <Z= represents a string of 9ero or ore characters" Any other character represents a single occurrence of itself" -n using the 1-,+ predicate! how do you do the following: Retrieve .A5+ that starts with NAO? o W*+R+ .A5+ 1-,+ NAZO Retrieve .A5+ whose 2nd character is NBO? o W*+R+ .A5+ 1-,+ NABZO Retrieve .A5+ whose 2nd to the last character is NRO? o W*+R+ .A5+ 1-,+ NZRAO Retrieve .A5+ whose last character is N[O? o W*+R+ .A5+ 1-,+ NZ[O Retrieve .A5+ that has N/O in their na e? o W*+R+ .A5+ 1-,+ NZ/ZO What is correlated su#-3uery? A correlated su#3uery is an inner 3uery that ust #e evaluated for each row of the outer 3uery" &he 3uery uses aliases to identify the ta#le references" +0a ple: %+1+)& +5(.'! 1A%&.A5+! 6-R%&.5+! %A1AR2 6R'5 D%.GTFC"+5( A W*+R+ FC Y <%+1+)& )'U.&<X= 6R'5 D%.GTFC"+5( B W*+R+ A"%A1AR2 S B"%A1AR2 A.D B"%A1AR2 -% .'& .U11= 'RD+R B2 %A1AR2 D+%)>

o &he alias VAW identifies the ta#le in the outer 3uery! so that in the
su#3uery! the A"%A1AR2 identifies that colu n as #elonging to the outer 3ueryMs ta#le" &he alias VBW is used for the su#3uery ta#le <though it is not re3uired=" What is referential integrity <R"-"=? &he state of a data#ase in which all values of all foreign keys are valid" 5aintaining referential integrity re3uires the enforce ent of referential constraints on all operations that change the data in a ta#le upon which the referential constraints are defined"

+0plain (ri ary ,ey and 6oreign ,ey concepts (R-5AR2 ,+2 is a uni3ue! non-null key that is part of the definition of a ta#le" A ta#le cannot #e defined as a parent unless it has a uni3ue key or pri ary key" 6'R+-4. ,+2 is a colu n or set of colu ns in a dependent ta#le of a constraint relationship" &he key ust have the sa e nu #er of colu ns! with the sa e descriptions! as the pri ary key of the parent ta#le" +ach foreign key value ust either atch a parent key value in the related parent ta#le or #e null"

What will happen if - delete a row with R"-"? 2ou cannot delete a row of the parent ta#le if records e0ist in the dependent ta#le" -f you specify )A%)AD+! delete the row of parent ta#le will delete the row if the child at the sa e ti e"

What are 8-+W%? A view is a virtual ta#le ade up of data fro #ase ta#les and other views! #ut not stored separately" We use views if we want to hide other colu ns to the users" 8iews can #e updated if there is only one #ase ta#le"

What are the isolation levels possi#le? )%: RR: )ursor %ta#ility Repeata#le Read

What is the difference #etween )% and RR isolation levels? )%: Releases the lock on a page after use RR: Retains all locks ac3uired till end of transaction

When do you specify the isolation level? *ow? During the B-.D process<-%'1A&-'. 1+8+1 is a para eter for the #ind process=" -%'1A&-'. < )%DRR =""" done with that page?

- use )% and update a page" Will the lock #e released after - a .o"

What are the various locking levels availa#le? (A4+! &AB1+! &AB1+%(A)+

*ow does DB2R Data#ase deter ine what lock-si9e to use? &here are three ethods to deter ine the lock-si9e" &hey are: F" Based on the lock-si9e given while creating the ta#lespace 2" (rogra er can direct the DB2R Data#ase what lock-si9e to use H" -f lock-si9e A.2 is specified! DB2R Data#ase usually chooses a lock-si9e of (A4+

What are the three lock types? &he three types are shared, update and exclusive" Shared locks allow two or ore progra s to read si ultaneously #ut not change the locked space" An exclusive lock #ars all other users fro accessing the space" An update lock is less restrictive> it allows other transactions to read or ac3uire shared locks on the space"

What are the disadvantages of (A4+ level lock? *igh resource utili9ation if large updates are to #e done

What is lock escalation? (ro oting a (A4+ lock-si9e to ta#le or ta#lespace lock-si9e when a transaction has ac3uired ore locks than specified in .U51,&%" 1ocks should #e taken on o#$ects in single ta#lespace for escalation to occur"

)an - use 1'), &AB1+ on a view? .o" &o lock a view! take lock on the underlying ta#les"

What is 4D4 <4eneration Data 4roup=? 4eneration Data 4roups or 4D4Os are a group of data sets which are related to each other chronologically and functionally" &hese related Data %ets share a uni3ue Data %et .a e" +very 4D4 data set has a 4eneration nu #er and 8ersion nu #er assigned to each data set" EXAMPLE -M521-B"1-B"&+%&"4CCCF8CCM M521-B"1-B"&+%&"4CCC28CCM M521-B"1-B"&+%&"4CCCH8CCM

S-- )urrent 8ersion

4eneration .u #er -Y 4aaaa8nn aaaa is #etween CCCC to JJJJ nn is #etween CC to JJ

-n Q)1: We refer current version with C +0a ple" 521-B"1-B"&+%&<C= .ew version going to create with EF +0a ple" 521-B"1-B"&+%&<EF= 'lder versions ! refer with -F -2 -H etc"""" +0a ple" 521-B"1-B"&+%&<-F= S- '1D+R 8+R%-'. +0a ple for where we can use this 4D4s: Usually! -n production environ ent! for every onth we need to run $o#s to create reports for that onth" 1et us suppose for QA.! We can code it MYLIB.LIB.TEST.JA for 6+B! We can code it MYLIB.LIB.TEST.!EB for 5AR! We can code it MYLIB.LIB.TEST.MA"

%o! every onth we need change dataset na e in Q)1! #efore su# itting the $o#" Whenever we entered into another year! we need to delete old yearOs data sets" We need to do a#ove task carefully! -f we use 4D4! -t will take care following things o o o o -t will aintain all generation of data sets -t will deleteDuncatalog older generation 8ery easily! we can refer current and older versions of data sets .o need of change the Q)1 every ti e when we su# it

*ow do you create a 4D4? Before using 4D4! we need to create 4D4 inde0 and odel"

*ow do you create a 4D4 inde0? -D)A5% <the MA5%M stands for Access 5ethod %ervices=! utility is used to create 4D4 inde0" +0a ple Q)1 for creating 4D4 inde0" DD52Q'B Q'B <W2HK=!O52.A5+O DD%&+(F +/+) (45B-D)A5% DD%2%-. DD X D+6-.+ 4D4<.A5+<521-B"1-B"&+%&= 1-5-&<FC= .'+5(&2 %)RA&)*= DX DD

-n this e0a ple! -D)A5% utility is used to create an inde0 for a 4D4 called 521-B"1-B"&+%&" &he nu #er of generations that can e0ist in this 4D4 is li ited to ten" .'+5(&2 para eter is used to specify ! 'nce the li it is reached! the syste is instructed to un-catalog the oldest generation data set within the 4D4" %)RA&)* para eter is used to specify to physically delete

the data set which was un-catalogued" (ara eters we can pass to -D)A5%" o o o .A5+: &his para eter is used to specify the na e of the data set that is to #e created" 1-5-&: &his para eter is used to specify the total nu #er of generations that the 4D4 ay contain" +5(&2D.'+5(&2: &hese two para eters are utually e0clusive" +5(&2 specifies that all e0isting generations of the 4D4 are to #e uncatalogued whenever the generations of 4D4 reached the a0i u li it" .'+5(&2 specifies that only the oldest generation of the 4D4 is to #e un-catalogued if the li it is reached" %)RA&)*D.'%)RA&)*: &hese two para eters are utually e0clusive" %)RA&)* para eter specifies that whenever entry of the 4D4 is re oved fro the inde0! it should #e deleted physically and catalogued" .'%)RA&)* para eter specifies that whenever entry of the 4D4 is re oved fro the inde0! it should #e catalogued! not physically deleted"

.ote: %)RA&)* and .'+5(&2 are default para eters" *ow do you create a 4D4 odel?

'nce the inde0 has #een created! a odel data set ust #e created" &his odel data set contains specifications for the D)B su#-para eters for all data sets that will #elong to that 4D4" (rogra er can override this default values if he want" EXAMPLE J#L DD52Q'B Q'B <WJGH=!M,R-%*.AM DD%&+(F +/+) (45B-D)A5% DD%2%-. DD X D+6-.+ 4D4< .A5+<521-B"1-B"&+%&= 1-5-&<FC= .'+5(&2 %)RA&)*= DD%&+(2 +/+) (45B-+6BRFK DD5'D+1F DD D%.B521-B"1-B"&+%&! DD D-%(B<.+W!,++(!D+1+&+=! DD U.-&B%2%DA! DD %(A)+<&R,!C=! DD D)BB<1R+)1BGC!R+)65B6B!B1,%-[+BGCC= DD Using -+6BRFK! we have created the odel"

*ow do you use a 4D4? &o use created 4D4 in our Q)1! we need to use na e <with EF for new generation= which we used in D+6-.+ 4D4 co and" <i"e" 521-B"1-B"&+%&="

EXAMPLE J#L DD52Q'B Q'B <%DHKI=!O52.A5+M DD%&+(F +/+) (45B)'B(R'4 DD-.6-1+ DD D%.B521-B"1-B"&+%&<EF=! DD D-%(B<.+W!)A&14!D+1+&+=! DD U.-&B%2%DA! DD %(A)+B<&R,!<2C!FC=!R1%+=! DD D)BB<5'D+1"D)B!R+)65B6B! DD 1R+)1BGC! DD B1,%-[+BGCC= DD &he progra )'B(R'4 is e0ecuted" A new generation data set is created via the state ent DD-.6-1+ DD D%.B521-B"1-B"&+%&<EF= %ince we used <EF= with 4D4 na e! it creates a new generation data set" &he D-%( para eter ust #e set to )A&14 for all new generation data sets ! D-%(B<.+W!)A&14!D+1+&+= We used 5'D+1"D)B in D)B para eter to instruct syste %u#-para eters specified in odel 4D4" .ote: &he D%. and U.-& para eters data sets" to use

ust #e coded for all new generation

-n y Q)1! -n stepF - will going to create a new generation data set for that - gave 4D4.A5+<EF=" -n step2! - want to use sa e data set created #y previous step? What nu #er - should give to refer that data set <i"e" C or EF or E2=? <%&+(F +/+)U&+D %U))+%%6U112=" Why? Use nu #er EF to refer to the dataset created #y the previous step" +ven stepF e0ecuted successfully! it is not #eco e the current generation of 4D4" At the end of the $o# only it will #eco e the current version of 4D4" %o within the $o# we need to refer it as new generation only! even that step co pleted successfully" in ascending

What is the )'B'1 %'R& ver#? &he %'R& ver# takes one or ore files of input records and sorts the or descending order #y one or ore progra er specified keys" &he result is a single sorted file" 6or at: %'R& sd-file-na e '. A%)+.D-.4DD+%)+.D-.4 ,+2 sd$ke%$&a'e \U%-.4 i&put$(ile$&a'e \ \-.(U& (R')+DUR+ -% routi&e$&a'e\

\4-8-.4 sorted$(ile$&a'e \ \'U&(U& (R')+DUR+ -% routi&e$&a'e\" sd$(ile$&a'e a te porary sort work file %D in the DA&A D-8-%-'. %+1+)& state ent in the +.8-R'.5+.& D-8-%-'. 5U%& #e )1'%+D when the sort is called key field fro the %D record description

sd$ke%$&a'e )SI * i&put$(ile$&a'e

this is the file that will #e sorted 6D in the DA&A D-8-%-'. %+1+)& st t in the +.8-R'.5+.& D-8-%-'. 5U%& #e )1'%+D when the sort is called

I P)T P"+#E,)"E IS routi&e$&a'e - routine-na e is a progra er coded routine that will select which records are to #e used in the sort - input procedure pseudocode: '(+. input-file-na e R+AD the first record While there are input records 5odify the current record 5'8+ record to sd-file-record R+1+A%+ sd-file-record R+AD ne0t record +ndwhile )1'%+ input-file-na e - &o release a record to the sort: R+1+A%+ sd-file-record ?6R'5 ws-area@" this is e3uivalent to a WR-&+ in )'B'1 e0cept that its perfor ed on an %D file and is used '.12 in an input procedure *I-I * sorted$(ile$&a'e this is the resulting sorted file 6D in the DA&A D-8-%-'. %+1+)& st t in the +.8-R'.5+.& D-8-%-'. 5U%& #e )1'%+D when the sort is called +)TP)T P"+#E,)"E IS routi&e$&a'e

- routine-na e is a progra er coded routine that will anipulate the records A6&+R they are sorted - output procedure pseudocode: '(+. sorted-file-na e R+&UR. the first sd-file-record While there are input records 5odify the sorted record 5'8+ sd-file-record to sorted-file-record WR-&+ sorted-file-record R+&UR. the ne0t sd-file-record +ndwhile )1'%+ sorted-file-na e - &o return a record: R+&UR. sd-file-na e ?-.&' ws-area@ ?A& +.D do so ething@ ?.'& A& +.D do so ething else@ +.D-R+&UR." this is e3uivalent to a R+AD in )'B'1 e0cept that it is perfor ed on an %D file and is used '.12 in an output procedure &he )'B'1 %'R& ver# calls %2.)%'R& to do its work" &here are so e PspecialP registers that are set #y the %'R& ver# and can #e set or tested #y a progra er" %'R&-R+&UR. after a %'R& this will contain a return code that can #e tested C FU success failure

if a progra er oves a non-9ero value to this register! the sort will stop on the ne0t R+&UR. or R+1+A%+ %'R&-6-1+-%-[+ e3uivalent to %2.)%'R&s 6-1%[

%'R&-5+%%A4+ can use this one to specify an G #yte ddna e for %2.)%'R& to write its essages to -n )'B'1: 5'8+ M%'R&'U&M &' %'R&-5+%%A4+" -n Q)1: DD%2%'U& DD %2%'U&BX DD%'R&'U& DD %2%'U&BX

*ow do you %'R& in a )'B'1 progra ? 4ive sort file definition! sort state ent synta0 and eaning" &he )'B'1 S+"T state ent is used in the P"+#E,)"E ,I-ISI+ to place records fro an input file in a te porary work file where their order will #e rearranged" &his work file is referred to as the sort .ork (ile" 'nce rearranged! the records can #e placed #ack in the original input file! placed in a separate output file! or processed #y the progra directly fro the sort work file" +.8-R'.5+.& D-8-%-'. entries &he input file! the sort file! and! if used! the output file ust each #e defined #y a SELE#T state ent in the I P)T$+)TP)T SE#TI+ ! !ILE$#+ T"+L paragraph" As with any other file! the SELE#T state ent for the sort file specifies #oth the internal and e0ternal filena es for the progra and for the 'perating %yste " SELE#T S+"T$!ILE ASSI* T+ ,IS/ 0S+"T1+"/.TMP2.

-n this e0a ple! the internal filena e is S+"T$!ILE and the e0ternal filena e is S+"T1+"/.TMP" &hese are progra er-supplied words! as with any file definition! and are chosen #ecause they are descriptive" &he D'% file e0tension &5( is chosen to re ind you that this is a te porary file" DA&A D-8-%-'. entries -n the !ILE SE#TI+ ! the input and output files would #e descri#ed as usual! using !, and record description entries" 6or the S+"T$!ILE! in place of an !, entry! a sort work file has a si ilar S, entry! which stands for Sort Description" &he record definition following the S, entry is called the sort record and ust #e #roken down enough to show the position and si9e of the sort key field(s)" 5ultiple keys can #e defined" All other fields can #e defined as filler entries if not used in the (rocedure Division" &he total nu #er of characters <su of the (-) si9es= within this record ust atch the nu #er of characters in the records to #e sorted" S, 34 S+"T$!ILE. S+"T$"E#+",. 35 35 S+"T$/EY 35 35 S"$) ITS 35 S"$#+ST 35

PI# X6537. PI# X687. PI# X6937. PI# :::. PI# :687-::. PI# X6487.

-n this e0a ple! S, is used instead of !, to descri#e the sort file in this division" &he file na e ust #e the sa e as the internal file na e in the +nviron ent Division" &he record is descri#ed to define the na e! position! data type! and si9e of the key field for use with the S+"T ver# in the (rocedure Division" 'ther fields that ay #e referenced #y the progra Os procedures are also defined" (R')+DUR+ D-8-%-'. state ent &he sort work file and the sort key field<s= are a ong the entries na ed in a S+"T state ent" &he na e of the work file ust follow the ver# S+"T" &his na e ust #e the sa e as the na e used in the SELE#T and S, entries" Records can #e arranged in either AS#E ,I * or ,ES#E ,I * se3uence #y

key field(s) specified" When ultiple key fields are used! they ust #e listed fro major to minor" )SI * and *I-I * clauses are used to specify the na e of the input data file and the na e of the output data file respectively" S+"T S+"T$!ILE AS#E ,I * S+"T$/EY, )SI * I P)T$!ILE, *I-I * +)TP)T$!ILE. -n this e0a ple! the S+"T ver# would perfor these procedures: F" &he file na ed I P)T$!ILE would auto atically #e opened for input! records read! rearranged! and stored in the sortOs work file in ascending se3uence according to the values in the key field of each record! and the file closed" 2" &he file na ed +)TP)T$!ILE would auto atically #e opened for output! the sorted records written to the file! and the file closed" &o sort the records! the progra er does not code any +PE ! #L+SE! "EA,! or 1"ITE state ents" &he S+"T causes all these operations to occur" After the S+"T ver# is co plete! the progra er ay open the resulting sorted file for input and process the records nor ally <#y using the ver#s '(+.! R+AD! )1'%+=" &his ay #e acco plished in the sa e progra or in a separate one" *ow do you define a sort file in Q)1 that runs the )'B'1 progra ? Use the %'R&W,CF! %'R&W,C2!""""" dd na es in the step" .u #er of sort datasets depends on the volu e of data #eing sorted! #ut a ini u of H is re3uired" ainfra e )'B'1?

What is the %'R& collating se3uence in

%orting takes place on the relative binary alues of the characters in the key field(s) of the sort record" 5ainfra e code sets is EB#,I# <+0tended Binary )oded Deci al -nterchange )ode=" )ollating se3uence is %pace! a-9! A-[! C-J"

What is %2.)*%'R&? SY #S+"T $ A +-E"-IE1

4. +-E"-IE1 %yncsort #elongs to %yncsort -nc) that can sort data! erge data! selectively process data! refor at data! create su ary records fro data and create e0tensive reports fro input data" -t can also perfor any co #ination of the a#ove entioned functions and ore" &his docu ent tries to e0plain in #rief the various ite s related to processing data using %yncsort" &his docu ent descri#es a su#set of the %yncsort functions and does not clai to #e a replace ent nor does the author guarantee the e0actness of details or synta0"

5. SY #S+"T #+MMA ,S

5.4 S+"T &he %'R& state ent can #e used sort a dataset or concatenated datasets" &he %'R& state ent re3uires the sort se3uence for the data" &he list of fields and their for ats ust #e specified for this state ent" &he output records are sorted in the specified se3uence" &he ultiple records contain the sa e sort se3uence key! then the options specified will deter ine if the input order is aintained for such records" &he for at of the %'R& state ent is as follows" %'R& 6-+1D%B<]#egcol^!]length^!]fieldtype^!]D\A^?!]#egcol^! ]length^!]fieldtype^! ]D\A^@"""= or %'R& 6-+1D%B<]#egcol^!]length^!]D\A^?!]#egcol^!]length^! ]D\A^@"""=!]fieldtype^ &he #eginning colu n is specified in #ytes! starting with F for the first #yte" &he length of the field ust #e specified in #ytes! irrespective of the field type" &here are any field types" &he fre3uently used ones are )* for character! B- for #inary <)'5( fields of )'B'1=! (D for packed deci al <)'5(-H fields of )'B'1=! [D for 9one deci al and A7 for alternate collating se3uence <refer to later section on alternate collating se3uence=" &he second for of the %'R& state ent can #e used when all the fields specified for the sort se3uence are of the sa e type" 5.5 ME"*E &he 5+R4+ state ent can #e used erge two or ore pre-sorted datasets" &he 5+R4+ state ent re3uires the sort se3uence for the data" &he list of fields and their for ats ust #e specified for this state ent" &he for at of the 5+R4+ state ent is as follows" 5+R4+ 6-+1D%B<]#egcol^!]length^!]fieldtype^!]D\A^?!]#egcol^! ]length^!]fieldtype^! ]D\A^@"""= or 5+R4+ 6-+1D%B<]#egcol^!]length^!]D\A^?!]#egcol^!]length^! ]D\A^@"""=!]fieldtype^ (lease refer to %'R& state ent a#ove for description of the state ent" 5.9 I #L),E A , +MIT &he -.)1UD+ state ent can #e used to specify the conditions for inclusion of records fro the input during processing" &he '5-& state ent can #e used to specify the conditions for e0clusion of records fro the input during processing" Both state ents cannot #e used together" &he different for ats of the -.)1UD+ and '5-& state ents are shown #elow" -.)1UD+ )'.DB<]#egcolF^!]lengthF^!]fldtypeF^!]co p"oper^! ]#egcol2^! ]length2^!]fldtype2^= &he a#ove state ent can #e used to co pare two fields within the sa e record" &he valid co parison operators are +7! .+! 4&! 1&! 1+ and 4+" -.)1UD+ )'.DB<]#egcol^!]length^!]fldtype^!]co p"oper^! ]constant^= &he a#ove state ent can #e used to co pare a field in the record with a character! deci al or he0adeci al constant" Using the convention that ]cond"st t^ is the part of state ent #etween the parenthesis in either of the state ents entioned a#ove! co pound state ents can #e constructed as follows" -.)1UD+ )'.DB<]cond"st t^!?]'R\A.D^!]cond"st t^@"""= (arenthesis can #e used to group conditional state ents to for co ple0 conditions" 6or '5-& state ents replace the -.)1UD+ ver# #y '5-& ver# in the a#ove e0a ples" 5.; I "E# A , +)T"E#

&he -.R+) state ent can #e specified to refor at the input records #efore %2.)%'R& processes the for %'R& or 5+R4+" &he 'U&R+) state ent can #e specified to refor at the processed records into the re3uired layout for the output records or the report that is generated" &he for at for the -.R+) and 'U&R+) state ents are si ilar" -.R+) 6-+1D%B<?]outpos^:@]#egcol^!]length^ ?!?]outpos^:@]#egcol^!]length^@"""= &he 'utpos description is optional" &his specifies the position in the output record where the field ust #e placed" &he default is to place it at the current position in the output record! placing the first field specified at colu n F" &he individual nu eric fields can also #e refor atted fro any for to 9one deci al" An e0a ple synta0 is given #elow" -.R+) 6-+1D%B<]#egcol^!]length^!]fldtype^!+D-&B5_= or -.R+) 6-+1D%B<]#egcol^!]length^!]fldtype^!+D-&B%---!--&"&&= Default picture clauses are provided and na ed 5C to 5J" )usto i9ed picture clauses can #e specified #y using appropriate synta0" -n the e0a ple a#ove! the % character is for sign field! - is e3uivalent of [ (-) clause of )'B'1 and & is e3uivalent of J (-) clause" )onventions for the sign displayed for nu eric fields can #e specified after the edit para eter! using %-4.% para eter" )onstant fields can also #e introduced in the record" 6or e0a ple! spaces or 9eroes can #e placed in the record at specific positions" !"#$: When using -.R+) fields! the colu n positions and lengths in the %'R&! 5+R4+ and %U5 state ents ust reflect the output fro the -.R+) processing" 5.8 S)M &he %U5 state ent can #e used to su ari9e data #ased on the %'R& state ent" 'ne record will #e produced for each uni3ue key present in the input" -f nu eric fields are specified for su ation! those fields will #e su ed up" &he %2.)%'R& software does not guarantee uni3ue records if nu eric fields are re3uired to #e su ed up" Whenever there is an overflow of a nu eric field! ore than one record ay #e created" &he synta0 is as follows" %U5 6-+1D%B.'.+ or %U5 6-+1D%B<]#egcol^!]length^!]fldtype^?!]#egcol^!]length^! ]fldtype^@"""= &he first for at is used when duplicate records need to #e re oved and no nu eric su ation is re3uired" &he second for at is used when nu eric su ation is re3uired when duplicate records e0ist" 5.< ALTE" ATE #+LLATI * SE=)E #E &he alternate collating se3uence can #e specified using the A1&%+7 state ent" &his will help the user in sorting records in a different se3uence than the +B)D-) character set" &his ay #e re3uired in situations where the character codes for fields! that the user intends to sort on! are not in +B)D-) collating se3uence" A1&%+7 )'D+B<]he0code^]newhe0code^?!]he0code^]newhe0code^@"""= &he new he0 code will #e used for the sorting or erging process only for the appropriate he0 code specified for it" &he new he0 code will not replace the he0 codes in the output or the reports" 5.> +PTI+ STATEME T &he option state ent can #e used to control para eters during %'R&! 5+R4+ and %U5 processing"

5.>.4 E=)ALS A , +E=)ALS &he default of .'+7UA1% specifies that %2.)%'R& need not retain the order of input data when duplicate record keys are found" '(&-'. +7UA1% should #e used if the order of input data ust #e aintained during the %'R& processing" &his para eter will affect the non-su ation data in %U5 processing" When +7UA1% is used the data for the non key fields are taken fro the first input record for that key value" When .'+7UA1% is specified the data for the non keyfields are unpredicta#le" 5.>.5 "E#+", &he record option of the '(&-'. state ent can #e used to specify if the input data to #e processed are 8aria#le length records or 6i0ed length records" &his is re3uired when #oth the input and output fro the %'R& or 5+R4+ processing are 8%A5 files" &he valid values are R+)'RDB8 and R+)'RDB6" 5.>.9 S/IP"E# &he %,-(R+) para eter of the '(&-'. state ent can #e used to specify the nu #er of records of input to skip #efore any processing should #egin" %,-(R+)B2C specifies that the first 2C records of the input ust #e skipped" 5.>.; ST+PA!T &he %&'(A6& para eter of the '(&-'. state ent can #e used to specify the nu #er of records to #e included for processing" %&'(A6&BFCC specifies that %2.)%'R& stop taken any ore input after FCC records that atch the criteria are selected" 5.>.8 #+PY &he )'(2 para eter can #e used if a si ple )'(2 operation is re3uired" -f neither %'R& processing nor 5+R4+ processing is re3uired this is ideal to use" &he para eter when co #ined with %,-(R+) and %&'(A6& helps copy selected records to output #ased on nu #er of records" -f )'(2 is co #ined with -.)1UD+ or '5-& condition state ents! selected records can #e copied to output #ased on specific conditions in field values" When )'(2 is co #ined with -.R+) or 'U&R+) processing <-.R+) is ore efficient in this case=! a refor atted output can #e produced" 5.? +)T!IL &he 'U&6-1 state ent can #e used to produce ultiple output datasets" &his state ent ust #e used if ela#orate for atting is re3uired! like producing reports" 'ne 'U&6-1 state ent is re3uired for each output dataset" &he 6-1+ para eter specifies the DD na e suffi0 to #e used for the dataset output" +ach output dataset can have its own -.)1UD+ or '5-& condition and its own -.R+) and 'U&R+) para eters" 6urther! report for atting is availa#le! including H levels of *+AD+R_! H levels of &RA-1+R_! su ation! %ection processing and %ection #reaks" 6or e0a ple! this state ent can help create separate reports for each depart ent into a different dataset or sysout and route the to the appropriate destination" &he %2.)%'R& anual should #e referred if the 'U&6-1 state ent is re3uired" 9. J#L "E=)I"EME TS &he different DD state ents re3uired for the %'R& step are as follows" 3 9.4.4.4 S%S&! 'e&tio&ed a@ove. It should poi&t to the SY #S+"T co&trol state'e&ts

SYSOUT -t should point to a dataset or %2%'U&" &his is where the %2.)%'R& essages are placed"

SORTIN This dataset should point to the input dataset(s) for the sort process. SORTIN## &hese state ents should refer to the individual datasets to #e erged" &hese individual datasets are re3uired to #e in pre-sorted order" SORTOUT &his dataset should point to the dataset where the output ust #e placed" SORTOUT# &hese datasets should point to the individual output datasets referred in the 'U&6-1 state ents" SORTOT## &he sa e as %'R&'U&_" &here ust #e a one to one correspondence #etween the 6-1+% para eter in the 'U&6-1 state ent and the list of DD state ents specified" SORTWK## &hese state ents should refer to te porary volu es with appropriate space para eters depending on the volu e of data to #e processed" ;. P"+#ESSI * +",E" &he processing order of the control state ents #y %2.)%'R& is as follows" C F" -.)1UD+ or '5-& condition state ent processing" F 2" -.R+) state ent processing" 2 H" %'R&! 5+R4+ or )'(2 processing <including alternate collating se3uence processing for %'R& and 5+R4+=" H K" %U5 state ent processing" K I" 'U&R+) processing" 2 &he processing order will drastically change if 'U&6-1 state ent is present in the %2%-. of %2.)%'R&" &he processing is very co ple0 if the 'U&6-1 state ents use different -.R+) state ents and different -.)1UD+ or '5-& state ents"

You might also like