db2 program preperation

Upload: sudheerrb

Post on 01-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 DB2 Program Preperation

    1/6

    COBOL Divisions:

    1) IDENTIFICATION DIVISION.  PROGRAM-ID. Entry  A!T"OR. #ntry.$ INSTALLATION. #ntry.$  DATE-%RITTEN. #ntry.$ O&tion'(

      DATA-COMPILED. #ntry.$  SEC!RIT. #ntry.$  REMAR*S. #ntry.$

    +) ENVIRONMENT DIVISION.  CONFIG!RATION SECTION.  SO!RCE-COMP!TER. so,r#-o&,t#r-#ntry.  OB/ECT-COMP!TER. o0#t-o&,t#r-#ntry.  SPECIAL NAMES. si'(-o&,t#r-#ntry$.  INP!T-O!TP!T SECTION.  FILE CONTROL. 23(#-ontro(-#ntry45.  I-O-CONTROL. in&,t-o,t&,t-ontro(-#ntry$.

    6) DATA DIVISION.  FILE SECTION.  LINKAGE SECTION

      %OR*ING-STORAGE SECTION.

    7) PROCED!E DIVISION.

    8) %OR*ING-STORAGE SECTION.9) EEC S;L DEPTNAME> MGRNO

    ?) FROM DEPT1@)%"ERE ADMRDEPT :ADMRDEPT11)FOR !PDATE OF MGRNO1+)END-EEC.

    EEC S;LDECLARE C!RSOR SAMPC!RS %IT" RO%SET POSITIONING FORSELECT DEPTNOFROM DSN=1@[email protected]

    END-EEC.

    O0#t D#sri&tion

    So,r# Ev#ry &ror' st'rts 's ' s#ri#s o ost ('n,'#st't##nts> non 's t# '&&(i'tion so,r#. T# so,r# is

    r,n tro, t# DB+ &r#-o&i(#r to 'v# its S;L

    st't##nts r#ov# 'n &('# in ' DBRM.Moi3# so,r# T# DB+ &r#-o&i(#r r#'t#s t# oi3# so,r# o,(#

    0y stri&&in t# so,r# o,(# o '(( its S;L st't##nts.

     T# oi3# so,r# is &'ss# to t# ost ('n,'#

    o&i(#r.

  • 8/9/2019 DB2 Program Preperation

    2/6

    Lo' o,(# T# (in'# #itor r#'t#s ' (o' o,(# ,sin t# o,t&,t o 

    t# ost ('n,'# o&i(#r. T# (o' o,(# ont'ins t#

    #H#,t'0(# or o t# ost ('n,'# st't##nts 'n is

    #H#,t'0(# it 'n '&&(i'tion &('n.DBRM T# DBRM is r#'t# 0y t# DB+ &r#-o&i(#r ro t# S;L

    st't##nts stri& ro t# &ror' so,r# o#.P''# A &''# '(so is r#'t# 0y t# BIND st't##nt. It ont'ins

    t# '#ss &'ts or ' sin(# DBRM. It ,st 0# si3# in

    t# &''# (ist o ' &('n 0#or# it 'n 0# #H#,t# it

    t# '&&ro&ri't# (o' o,(# or t# &ror').P('n A &('n is r#'t# 0y t# BIND st't##nt. It onsists o ' (ist

    o on# or or# &''#s. T# &('n is #H#,t'0(# it t#

    orr#s&onin &ror' (o' o,(#.Co((#tion A o((#tion is 'n i#nti3#r ,s# to ontro( t# r#'tion o

    ,(ti&(# &''#s ro t# s'# DBRM. T#ni'((y> '

    o((#tion is not 'n o0#t> 0,t it is in(,# in tis (ist or

    o&(#t#n#ss.)V#rsion A v#rsion is ' to#n si3# to t# DB+ &r#-o&i(#r t't

    #n'0(#s ,(ti&(# v#rsions o t# s'# o((#tion 'n

    &''# to #Hist.

    DB+ Co(,n Byt#s COBOL PIC C(',s# Byt#s

    SMALLINT + PIC S?@7) COMP +

    INTEGER 7 PIC S?@?) COMP 7

    DECIMAL &> J)

    P so,( 0# (#ss t'n 6+)

    Int PK+) PIC S?&-J)V?J) Int##r

    P;)K+ 1)

    DATE 7 PIC 1@) =

     TIME 6 PIC @=) 9

     TIMESTAMP 1@ PIC +9)

    yyyy---

    ..ss.nnnnnn

    +9

    C"ARn) n1 to +87) N PIC n) N

    VARC"ARn) n@-7@79) N @1 %S-COL!MN.

    7? %S-COL!MN-

    LENGT" PIC

    S?@7) COMP

    7? %S-COL!MN

    N+

  • 8/9/2019 DB2 Program Preperation

    3/6

     TET PIC n)

    Data Type COBOL Data Declaration Comments

    'r @1 identifer  PIC n).

    @1 identifer  PICT!RE IS n).

    n is ' &ositiv# int##rr#&r#s#ntin t# (#nt o t#C"AR o(,n v'(,# 'ssin# tot# ost v'ri'0(#.

    v'r'r @1 i#nti3#r

    7? identifer  PIC S?ni) COMP.

    7? identifer  PIC nc).

    ni is ' &ositiv# int##r ro 1 to7> r#&r#s#ntin t# (#nt o t#n,#ri o(,n v'(,# 'ssin#to t# v'ri'0(# ont'inin t#strin (#nt.

    nc is ' &ositiv# int##r #J,'( tot# (#nt o t# ('r#stVARC"AR o(,n v'(,# t't 'n0# 'ssin# to t# ost v'ri'0(#.

    s'((int @1 identifer  PIC S?7) COMP.

    @1 identifer  PIC S?n) COMP.

    @1 identifer  PIC S?n) !SAGE ISCOMP.

    n is ' &ositiv# int##r ro 1 to7> r#&r#s#ntin t# v'ri'0(#(#nt. No #i'( &oints 'r#'((o#. Anytin ot#r t'n ?sin t# Pit,r# (',s# '#s 't'it# ,n'#&t'0(# 's ' ostv'ri'0(#. PIC S 'n COMP 'r#r#J,ir#. o, 'y ,s# COMP-7

    or COMP-8 in &('# o COMP in##ss'ry.

    int##r @1 identifer  PIC S??) COMP.

    @1 identifer  PIC S?n) COMP.

    @1 identifer  PIC S?n) !SAGE ISCOMP.

    n is ' &ositiv# int##r ro 8 to?. No #i'( &oint is '((o#.Anytin ot#r t'n ?s in t#Pit,r# (',s# i(( '# t#'t' it# ,n'#&t'0(# 's 'ost v'ri'0(#. PIC S 'n COMP'r# r#J,ir#. o, 'y ,s#COMP-7 or COMP-8 in &('# oCOMP i n##ss'ry.

    #i'( @1 identifer  PIC S?V COMP-6.

    @1 identifer  PIC S?n) V COMP-6.

    @1 identifer  PIC S?n) V?m) COMP-6.

    @1 identifer  PIC S?n) V?m) !SAGEIS COMP-6.

    n 'n m 'r# &ositiv#

    int##rs n  m 'nnot #H##18. o, ,st in(,# ' V to#not# t# #i'( &oint.Anytin ot#r t'n ?s 'n ' Vin t# Pit,r# (',s# i(( '#t# 't' it# ,n'#&t'0(# 's 'ost v'ri'0(#. PIC S 'n COMP-6.'r# r#J,ir#.

  • 8/9/2019 DB2 Program Preperation

    4/6

    o't @1 identifer  COMP-+.

    @1 identifer  !SAGE IS COMP-6.

    COMP-+. or COMP-6. is r#J,ir#.

    't# @1 identifer  PIC n).

    @1 identifer  PICT!RE IS n).

    n ,st 0# 'n int##rr#&r#s#ntin t# (#nt o t#'t# strin. For #H'&(#> i t#

    't# strin is in t# or'tMMKDDK> n 'y #J,'( =. I int# or't MMKDDK> nso,( #J,'( 1@. M'# s,r# yo,r't# or't is s#t orr#t(y int# O&tions ,ti(ity. S## t#O&tion ,ti(itys on(in# #(& orinor'tion '0o,t oiyin t#'t#Kti# r#&r#s#nt'tion.

    ti# @1 identifer  PIC n).

    @1 identifer  PICT!RE IS n).

    n ,st 0# 'n int##rr#&r#s#ntin t# (#nt o t#ti# strin. To in(,#

    s#ons> n ,st 0# 't (#'st =.For #H'&(#> ' ti# strin in t#or't "":MM r#J,ir#st't n #J,'( 't (#'st 8> i(# 'ti# strin in t# or't"":MM:SS r#J,ir#s t't n #J,'('t (#'st =.

    r#s,(t s#t(o'tor

    @1 i#nti3#r S;L TPE IS RES!LT-SET- LOCATOR.

    A 7-0yt# v'(,# ,s# 0y DB+ to,niJ,#(y i#ntiy ' J,#ry r#s,(ts#t r#t,rn# 0y ' stor#&ro#,r#.

    0C4,0C5,

    0C6Addressing program check 

    • Runaway or uninitialized subscript or index

    • issing or in!alid "" statement

    • Reading #rom or writing to an unopened #ile

    • $pening or closing the #ile twice

    • "ropping o## the end o# the program

    • %sing a di!isor or multiplier that is too large

  • 8/9/2019 DB2 Program Preperation

    5/6

    • %sing the wrong &$R'()* in a C$*$( sort

    0C+

    "ata exception program check 

    • "ata item not initialized

    • ")&(A- data mo!ed to a numeric group item

    • )mproper de#inition in the ()./A1 &1C')$.

    • )n!alid or misaligned data in an input #ile

    • )mproper initialization using $21 31R$

    • Runaway or uninitialized subscript or index

    'he ob exceeded the amount o# time allowed by the system or by the ')1

     parameter o# the 7$* or 181C 7C( statement9 Check to determine i# the programis looping9

    +'he disk doesn:t ha!e enough space to allocate the #ile

    +

    'he number o# print lines exceeds the system limit #or the #ile9 Check to determine

    i# your program is looping9 )# not, modi#y the 7C( to increase the number o# lines

     permitted9

    ;06

    A re

  • 8/9/2019 DB2 Program Preperation

    6/6

     program loop that contains a =R)'1 statement9

    1+

    'he disk does not contain enough a!ailable space to allocate the amount re