Cobol Db2 Program Dclgen
Cobol Db2 Program Dclgen
Cobol Db2 Program Dclgen
STEP 1.
EMPNAME
XXXXXXX
YYYYYYY
ZZZZZZZ
DEPARTMENT
XX
YY
ZZ
SALARY
10000
9000
20000
DESIGNATION
SE
SE
MA
CHAR(10)
NOT NULL,
CHAR(30)
NOT NULL,
CHAR(2)
NOT NULL,
DECIMAL(10,2)
NOT NULL,
CHAR(4)
NOT NULL )
STEP 2.
EMPOYEE-RECORD.
05 HV-EMPID
05 HV-EMPNAME
05 HV-DEPARTMENT
05 HV-SALARY
05 HV-DESIGNATION
PIC X(10).
PIC X(30).
PIC X(2).
PIC S9(8)V99 COMP-3.
PIC CHAR(4).
also
If you use db2 tool DCLGEN, it will automatically creates this structure
along with table declaration specified in step1.
STEP 3.
STEP 4.
HV-SALARY
ELSE
DISPLAY ' SQL FAILED '
DIAPLY ' SQL CODE
'
SQLCODE
END-IF.
....
....
DISPLAY ' PROGRAM ENDED'.
Here SQLCODE = 0 means, sql ran sucessfully without any issues. Hence
//
REGION=4M
//STEPLIB DD DISP=SHR,
//
DSN=XXXX.XXXXXX
//SYSIN
DD DISP=(OLD,DELETE),
//
DSN=&&TEMP
//SYSLIN
DD DISP=(MOD,PASS),
//
DSN=&&LOADTMP,
//
SPACE=(800,(500,500)),
//
UNIT=SYSDA
//********************************************************************
//*--------------SOURCE LIBRARIES FOR COBOL DB2 CODE (COPY LIBRARIES)*
//********************************************************************
//SYSLIB
DD DISP=SHR,
//
DSN=DEV.SURESH.DCL
<----------------- (4)
//
DD DSN=DEV.SURESH.CPY,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSUT1
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT2
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT3
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT4
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT5
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT6
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//SYSUT7
DD SPACE=(800,(500,500),,,ROUND),
//
UNIT=SYSDA
//*
//*
//********************************************************************
//*
LINK EDIT
*
//********************************************************************
//*
//LKED
EXEC PGM=IEWL,
//
COND=((4,LT,COB),(4,LT,PC)),
//
PARM='XREF'
//SYSLIB
DD DISP=SHR,
//
DSN=SXXX.SXXXXXXX
//
DD DISP=SHR,
//
DSN=XXXX.DB2.XXX.XXXXLOAD
//
DD DISP=SHR,
//
DSN=SYS1.VSCLLIB
//SYSLIN
DD DISP=(OLD,DELETE),
//
DSN=&&LOADTMP
//*
DD DDNAME=SYSIN
//********************************************************************
//*----------------LOCATION OF LOAD LIBRARY--------------------------*
//SYSLMOD DD DISP=SHR,
//
DSN=DEV.SURESH.LOADLIB(DB2PROG)
<------------ (5)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSUT1
DD SPACE=(1024,(50,50)),
//
UNIT=SYSDA
//*
//********************************************************************
//*
BIND - BIND THE DB2 PACKAGE
*
//********************************************************************
//BIND
EXEC PGM=IKJEFT01,
//
COND=(4,LT),
//
REGION=4096K
//STEPLIB DD DISP=SHR,
//
DSN=XXX4.DB2.XXXX.XXXXLOAD
//DBRMLIB DD DISP=SHR,
//
DSN=DEV.SURESH.DBRM(DB2PROG)
<--------------- (6)
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM (DEVDB
)
BIND MEMBER
(DB2PROG) PACKAGE
(PACKG11) LIBRARY
('DEV.SURESH.DBRM') <---------------- (7)
ACTION
(REP) ISOLATION (CS) VALIDATE (BIND)RELEASE
(COMMIT) OWNER
(SURESH) QUALIFIER (DEVQUALI)
END
/*
**************************** Bottom of Data ****************************
(1)
(2)
(3)
(4)
(5)
(5) & (6) - specify the location of DBRM, ( same location used in step1 ).