Upload
asim-javed
View
219
Download
0
Embed Size (px)
Citation preview
7/24/2019 Db2 Training Class 004
1/23
www.mainframes-online-training.weebly.com Polsani Anil Kumar
COBOL-DB2 Program
DB2 Training Class 04
http://www.mainframes-online-training.weebly.com/http://www.mainframes-online-training.weebly.com/http://www.mainframes-online-training.weebly.com/7/24/2019 Db2 Training Class 004
2/23
Required Steps
Write a COBOL + DB2 rogramComile t!e COBOL + DB2 rogram
"#ecute t!e rogram.
7/24/2019 Db2 Training Class 004
3/23
Required Copyboos
SQLCAcoy boo$
Hostvariable/DCLGENcoyboo$
Alication rogram containing %&L statement s!oul' !a(e %&LCA
coyboo$. %&LCA coyboo$ is a collection of (ariables t!at areu'ate' for e(ery %&L statement.
)!is coyboo$ is of 136bytes in lengt!.
Contains most imortant (ariable li$e %&LCOD"* %&L"D
SQLCODEcontain t!e status co'e after e(ery "#ecution of %&L
statement w!ose icture clause is S9(9,COMP-3.
SQLERRDis an occurs 'ata item in w!ic! t!e occurrence contains
t!e number of effecte' rows by a gi(en uery i.e. SQLERRD(3,.
7/24/2019 Db2 Training Class 004
4/23
!ost "ariable
)!ese are (ariable 'efine' in t!e ostla!"#a"eto use in
alication rogram.
/ost 0ariable are t!e only means of mo(ing 'ata from an'
to DB2 tables
We use DCLGEN tool to ro'uce !ost (ariable are t!e
same as t!e column of t!e tables
We nee' to co'e !ost (ariables wit! in t!e %&L statement
but s!oul' be rece'e' by $olo!(%&'
7/24/2019 Db2 Training Class 004
5/23
#mbedded S$L
All t!e %&L relate' statement s!oul' be co'e'1embe''e' in
between
""C%&L 3 "4D-""C.
Bot! %&LCA an' !ost (ariable s!oul' be co'e' in between
""C %&L an' "4D-""C wit! 54CL6D" %tatement.
""C%&L ""C%&L
54CL6D" %&LCA 54CL6D" DCL7"4
"4D-""C. "4D-""C.
7/24/2019 Db2 Training Class 004
6/23
#mbedded S$L Statement
""C%&L 54%") 54)O "8P9)AB:"4O*"4A8",
0AL6"%:;/%-"4O*;/%-"4A8",
"4D-""C.
""C%&L %"L"C) "4O*"4A8" 54)O ;/%-"4O*;/%-"4A8">?
"4D-""C.
""C%&L 6PDA)" "8P9)AB %") "4A8"=;/%-"4A8"
"4D-""C.
""C%&L D"L")"
7/24/2019 Db2 Training Class 004
7/23
Program Preparation
We nee' to follow few stes
Precomile
Comile3 lin$
Bin'
Pac$age:B54DPACKA7",
Plan:B54DPLA4,
7/24/2019 Db2 Training Class 004
8/23
7/24/2019 Db2 Training Class 004
9/23
Pre%ompile
%earc!esall t!e %&L statements an' inclu'e members an'
comments out e(ery %&L statements in t!e rogram
)!e %&L statement are relace'by a callstatement along
wit! t!e arameters
All %&L statements are e#tracte'an' ut in a DB8
Bot! %&LCA 3 DCL7"4 coyboo$s are e#an'e' in t!e
re comile rocess only.
5t also assign a time stam to t!e mo'ifie' co'e an' DB8
member.
7/24/2019 Db2 Training Class 004
10/23
Compile and Lin
8o'ifie' COBOL co'e outut is t!en comile'
Comile' co'e is t!en lin$ e'ite' to an "#ecutable
loa' mo'ule
7/24/2019 Db2 Training Class 004
11/23
B&'D Pro%ess
A tye of comiler for %&L statement using a re written
rogram i.e. 5K@"?
5t rea's t!e %&L statement from t!e DB8 an' ro'uces a
mec!anism to access 'ata as 'irecte' by t!e %&L statement
5n t!is bin' rocess it c!ec$s t!e synta#* c!ec$s for t!e
correctness of t!e table 3 columns 'efinitions against t!e
catalog information an' erform aut!entication (ali'ation
)!e outut of t!e bin' rocess can be a ac$age or a lan
7/24/2019 Db2 Training Class 004
12/23
Pa%age ( its )d"antage
Pac$age is boun' form of %&L statement
Ava!ta"es;
e'uce' bin' time
Can secify bin' oeration in t!e rogrammer le(el
Pro(i'e remote 'ata access
7/24/2019 Db2 Training Class 004
13/23
PL)'
Pac$age is not "#ecutable w!ere as lan is "#ecutable
An alication lan contain one or bot! of t!e following
elements
A list of ac$age names
)!e boun' form of %&L statement ta$en from one or more
DB8
"(ery DB2 alication reuires an alication lan
Plans are create' using t!e DB2 sub comman' B54D PLA4
7/24/2019 Db2 Training Class 004
14/23www.mainframes-online-training.weebly.com Polsani Anil Kumar
Bind Parameters
http://www.mainframes-online-training.weebly.com/http://www.mainframes-online-training.weebly.com/http://www.mainframes-online-training.weebly.com/7/24/2019 Db2 Training Class 004
15/23
Bind Parameters
11%%)%54 DD
D%4 %%)"8:DB7,
B54D PACKA7":
7/24/2019 Db2 Training Class 004
16/23
Bind Parameters
PKL5%); PKL5%) is a bin' arameter of bin' lan. Pac$ages to be
connecte' wit! lan are name' !ere.
AC)5O4:ADDE"PLAC", ac$age or lan is a'' or relace'. 'efault
is "PLAC".
AC&65"A4D "L"A%";
AC&65":6%"1ALLOCA)"loc$s table an' table sace on use
"L"A%":CO885)1D"ALLOCA)", release w!en t!e lan
terminates
%&L"O:4OPACKA7"1CO4)546", it says weat!er to create t!e
ac$age in case of sl error
"PLA54:"%14O, loa's t!e access at! selecte' by t!e otimFerin
lan9table. no is 'efault
7/24/2019 Db2 Training Class 004
17/23
&solation Le"els
Lost *+ates% )!is e(ent occurs w!en two
transactions rea' t!e same 'ata* bot! attemt to
u'ate t!at 'ata* an' one of t!e u'ates is lost.
Dirt, Reas% )!is e(ent occurs w!en a transaction
rea's 'ata t!at !as not yet been committe'.
No!re+eatable Reas% )!is e(ent occurs w!en a
transaction rea's t!e same row of 'ata twice* but gets
'ifferent results eac! time
Pa!tos')!is e(ent occurs w!en a row of 'ata
matc!es some searc! criteria but initially is not seen.
7/24/2019 Db2 Training Class 004
18/23
&solation le"els
Re+eatable ReaRea Stabilit,
C#rsor Stabilit,
*!$oitte Rea
7/24/2019 Db2 Training Class 004
19/23
.e Re+eatable Rea &solation Le"el
)!e eeatable ea' isolation le(el is t!e most restricti(e
isolation le(el a(ailable.
W!en t!is isolation le(el is use'* e(ery row t!at is reference'
in any manner by t!e isolate' transaction is Gloc$e'G for t!e'uration of t!at transaction.
)!us* if a transaction scans ?*>>> rows in or'er to retrie(e ?>*
loc$s are acuire' an' !el' on all ?*>>> rows scanne'Hnot
Iust on t!e ?> rows retrie(e'.
7/24/2019 Db2 Training Class 004
20/23
T*e Read Stability &solation Le"el
w!en t!e ea' %tability isolation le(el is use'* only rows t!atare actually retrie(e' by a single transaction are loc$e' for t!e
'uration of t!at transaction.
!antoms* !owe(er* can an' may be seen.
if a transaction scans ?*>>> rows in or'er to retrie(e ?>* loc$s
are only acuire' an' !el' on t!e ?> rows retrie(e'Hnot on all
?*>>> rows scanne'.
An' because fewer loc$s are acuire'* more transactions canrun concurrently.
7/24/2019 Db2 Training Class 004
21/23
T*e Cursor Stability &solation Le"el
W!en t!e Cursor %tability isolation le(el is use'* only t!e row
t!at is currently being reference' by a cursor is loc$e'. )!e
loc$ acuire' remains in effect until t!e cursor is reositione'
Hmore often t!an not by e#ecuting t!e
7/24/2019 Db2 Training Class 004
22/23
T*e +n%ommitted Read &solationLe"el
)!e uncommitte' rea' isolation le(el is t!e least intrusi(eisolation le(el ro(i'e'.
5n fact* w!en t!e uncommitte' rea' isolation le(el is use'* rows
t!at are retrie(e' by a single transaction are only loc$e' if
anot!er transaction attemts to 'ro or alter t!e table from w!ic!
t!e rows were retrie(e'. Because rows often remain unloc$e'
W!en t!is isolation le(el is use'* 'irty rea's* nonreeatable
rea's* an' !antoms can occur.
)!e uncommitte' rea' isolation le(el is commonly use' for
transactions t!at access rea'-only tables1(iews or transactions
t!at e#ecute ueries on w!ic! uncommitte' 'ata from ot!er
transactions will !a(e no a'(erse affect
7/24/2019 Db2 Training Class 004
23/23
T*an ,ou