IDENTIFICATION DIVISION.
00010000
PROGRAM-ID. FIRSTDB2.
00020000
AUTHOR. SRIRAM.
00030000
*Create a table in database
ENVIRONMENT DIVISION.
00040000
INPUT-OUTPUT SECTION.
00050000
FILE-CONTROL.
00060001
DATA DIVISION.
00070000
FILE SECTION.
00080000
WORKING-STORAGE SECTION.
00090000
01 WSS-ERR-MSG.
00100000
05 WS-ERR-MSG.
00110000
10 WS-ERR-LEN
PIC S9(4) COMP VALUE 800.00120000
10 WS-ERR-TEXT
PIC X(80)
00130000
OCCURS 10 TIMES. 00140000
05 WS-ERR-LRECL
PIC S9(9) COMP VALUE 80. 00150000
05 WS-DB2-ERRMSG-IDX
PIC 9(2).
00160000
05 WS-ERROR-MESSAGE
PIC X(120).
00170000
05 WS-SQLCODE-CODE
PIC S9(3)
00180000
SIGN LEADING SEPARATE.00190000
01 WS-SQLCODE-ERR
PIC S9(03)
00200000
SIGN LEADING SEPARATE.00210000
88 C01-IND-EM-SUCCESS
VALUE +000.
00220000
88 C01-IND-EM-DUPTABLE
VALUE -601.
00230000
88 C01-IND-EM-DB-NOT-FND
VALUE -204. 00240000
88 C01-IND-EM-ILLEGAL-SYMBOL
VALUE -104. 00250000
88 C01-IND-EM-ILLEGAL-KEYWORD
VALUE -199. 00260000
EXEC SQL
00261002
INCLUDE SQLCA
00262002
END-EXEC
00263002
PROCEDURE DIVISION.
00270000
0000-MAIN-PARA.
00290000
PERFORM 1000-INITIALIZATION-PARA
00300000
THRU 1000-INITIALIZATION-PARA-EXIT
00310000
PERFORM 2000-PROCESS-PARA
00320000
THRU 2000-PROCESS-PARA-EXIT
00330000
PERFORM 9000-TERMINATION-PARA
00340000
THRU 9000-TERMINATION-PARA-EXIT
00350000
.
00360000
0000-MAIN-PARA-EXIT.
00370000
EXIT
00380000
.
00390000
1000-INITIALIZATION-PARA.
00410000
INITIALIZE WS-SQLCODE-ERR
00420000
.
00430000
1000-INITIALIZATION-PARA-EXIT.
00440000
EXIT
00450000
.
00460000
2000-PROCESS-PARA.
00480000
EXEC SQL
00520000
CREATE
00530000
TABLE
00540000
TB_CRICKET_PLAYERS_DETAILSS
00550011
(
00560000
EMPLOY_ID
NUMERIC(4) NOT NULL
00570007
,EMPLOY_FNAME
VARCHAR(17)
00580000
,EMPLOY_COUNTRY
CHAR(5)
00590000
,EMPLOY_STATE CHAR(13)
00600009
,SALARY
NUMERIC(6,0)
00640006
,DATEE DATE
00650010
,PRIMARY
KEY(EMPLOY_ID)
00660000
)
00670000
IN
00680000
DBTCHN03.TSCAT04
00690000
END-EXEC
00700000
.
00720000
MOVE SQLCODE TO WS-SQLCODE-ERR.
00740000
MOVE SQLCODE TO WS-SQLCODE-CODE.
00750000
00760000
EVALUATE TRUE
00770000
WHEN C01-IND-EM-SUCCESS
00780000
DISPLAY 'CREATED
SUCCESSFULLY'
00790000
DISPLAY WS-SQLCODE-CODE
00800000
WHEN C01-IND-EM-DUPTABLE
00810000
DISPLAY 'THE TABLE NAME
ALREADY EXISTS' 00820000
DISPLAY WS-SQLCODE-CODE
00830000
DISPLAY SQLCODE
00840000
CALL 'DSNTIAR' USING
SQLCA,
00850000
,WS-ERR-MSG
00860003
,WS-ERR-LRECL
00870000
DISPLAY WS-ERR-MSG
00880000
WHEN C01-IND-EM-DB-NOT-FND
00890000
DISPLAY 'CHECK THE DATABASE NAME. IT
IS NOT VALID' 00900000
DISPLAY WS-SQLCODE-CODE
00910000
WHEN C01-IND-EM-ILLEGAL-SYMBOL
00920000
DISPLAY 'CHECK THE BRACES,COMMA,AND
SPELLINGS.INVALID'00930000
DISPLAY WS-SQLCODE-CODE
00950000
WHEN C01-IND-EM-ILLEGAL-KEYWORD
00960000
DISPLAY 'CHECK SPLELLINGS OF THE
KEYWORDS.ITS INVALID'00970000
DISPLAY WS-SQLCODE-CODE
00990000
WHEN OTHER
01000000
CALL 'DSNTIAR' USING
SQLCA,
01010000
WS-ERR-MSG
01020000
WS-ERR-LRECL
01030000
DISPLAY
WS-ERR-MSG
01040000
END-EVALUATE
01050000
.
01060000
2000-PROCESS-PARA-EXIT.
01070005
EXIT
01080000
.
01090000
9000-TERMINATION-PARA.
01110005
STOP RUN
01120000
.
01130000
9000-TERMINATION-PARA-EXIT.
01140005
EXIT
01150000
.
01160000
No comments:
Post a Comment