IDENTIFICATION DIVISION.
PROGRAM-ID. DML028.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. xyz.
OBJECT-COMPUTER. xyz.
DATA DIVISION.
WORKING-STORAGE SECTION.
* Standard COBOL (file "DML028.SCO") calling SQL
* procedures in file "DML028.MCO"
****************************************************************
*
* COMMENT SECTION
*
* DATE 1988/04/28 STANDARD COBOL LANGUAGE
* NIST SQL VALIDATION TEST SUITE V6.0
* DISCLAIMER:
* This program was written by employees of NIST to test SQL
* implementations for conformance to the SQL standards.
* NIST assumes no responsibility for any party's use of
* this program.
*
* DML028.SCO
* WRITTEN BY: HU YANPING
* TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE
*
* THIS ROUTINE TESTS THE OPEN STATEMENT IN THE LANGUAGE OF
* SQL. THE FORMAT:
* OPEN <cursor name>
*
* REFERENCES
* AMERICAN NATIONAL STANDARD database language - SQL
* X3.135-1989
*
* SECTION 8.3 <declare cursor>
* SECTION 8.6 <fetch statement>
* SECTION 8.7 <insert statement>
* SECTION 8.8 <open statement>
*
****************************************************************
* EXEC SQL BEGIN DECLARE SECTION END-EXEC
01 PNO1 PIC X(3).
01 EMPNO1 PIC X(3).
01 SCITY PIC X(15).
01 PCITY PIC X(15).
01 HOURS1 PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
* EXEC SQL END DECLARE SECTION END-EXEC
01 i PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
01 ii PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
01 uid PIC X(18).
01 uidx PIC X(18).
01 SQL-COD PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
01 SQLCODE PIC S9(9) COMP.
01 errcnt PIC S9(4) DISPLAY SIGN LEADING SEPARATE.
* date_time declaration *
01 TO-DAY PIC 9(6).
01 THE-TIME PIC 9(8).
PROCEDURE DIVISION.
P0.
MOVE "HU" TO uid
CALL "AUTHID" USING uid
MOVE "not logged in, not" TO uidx
CALL "AUTHCK" USING SQLCODE uidx
MOVE SQLCODE TO SQL-COD
if (uid NOT = uidx) then
DISPLAY "ERROR: User " uid " expected."
DISPLAY "User " uidx " connected."
DISPLAY " "
STOP RUN
END-IF
MOVE 0 TO errcnt
DISPLAY
"SQL Test Suite, V6.0, Module COBOL, dml028.sco"
DISPLAY " "
DISPLAY
"59-byte ID"
DISPLAY "TEd Version #"
DISPLAY " "
* date_time print *
ACCEPT TO-DAY FROM DATE
ACCEPT THE-TIME FROM TIME
DISPLAY "Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME
******************** BEGIN TEST0126 *******************
DISPLAY " TEST0126 "
DISPLAY " OPEN, CLOSE, OPEN again to check. "
DISPLAY "reference X3.135-1989 section 8.8 General Rules"
DISPLAY " - - - - - - - - - - - - - - - - - - -"
DISPLAY " *** EXEC SQL DECLARE X CURSOR "
DISPLAY " *** FOR SELECT EMPNUM,HOURS "
DISPLAY " *** FROM WORKS "
DISPLAY " *** ORDER BY EMPNUM DESC,HOURS DESC "
* EXEC SQL DECLARE X CURSOR
* FOR SELECT EMPNUM,HOURS
* FROM WORKS
* ORDER BY EMPNUM DESC,HOURS DESC END-EXEC
* EXEC SQL OPEN X;
CALL "SUB1" USING SQLCODE
MOVE SQLCODE TO SQL-COD
MOVE 0 TO i
PERFORM P50 UNTIL i > 6
* EXEC SQL CLOSE X;
CALL "SUB2" USING SQLCODE
MOVE SQLCODE TO SQL-COD
* EXEC SQL OPEN X;
CALL "SUB1" USING SQLCODE
MOVE SQLCODE TO SQL-COD
* EXEC SQL FETCH X INTO :EMPNO1,:HOURS1;
CALL "SUB4" USING SQLCODE EMPNO1 HOURS1
MOVE SQLCODE TO SQL-COD
DISPLAY "After close and open again, the first row should be
- " fetched."
DISPLAY " EMPNO1=", EMPNO1 " and HOURS1=",
HOURS1 " "
if (EMPNO1 = "E4" AND HOURS1 = 80) then
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0126','pass','MCO') END-EXEC
CALL "SUB5" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " *** pass *** "
else
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0126','fail','MCO') END-EXEC
ADD 1 TO errcnt
CALL "SUB6" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " dml028.sco *** fail *** "
END-IF
DISPLAY "================================================"
DISPLAY " "
* EXEC SQL COMMIT WORK;
CALL "SUB7" USING SQLCODE
MOVE SQLCODE TO SQL-COD
******************** END TEST0126 *******************
******************** BEGIN TEST0127 *******************
DISPLAY " TEST0127 "
DISPLAY " OPEN two cursors at same time to check. "
DISPLAY "reference X3.135-1989 section 8.8 General Rules"
DISPLAY " - - - - - - - - - - - - - - - - - - -"
DISPLAY " *** EXEC SQL DECLARE Y CURSOR "
DISPLAY " *** FOR SELECT EMPNUM,PNUM"
DISPLAY " *** FROM WORKS "
DISPLAY " *** ORDER BY EMPNUM DESC,PNUM DESC "
* EXEC SQL DECLARE Y CURSOR
* FOR SELECT EMPNUM,PNUM
* FROM WORKS
* ORDER BY EMPNUM DESC,PNUM DESC END-EXEC
* EXEC SQL DECLARE Z CURSOR
* FOR SELECT CITY
* FROM STAFF
* WHERE EMPNUM = :EMPNO1 END-EXEC
* EXEC SQL DECLARE A CURSOR
* FOR SELECT CITY
* FROM PROJ
* WHERE PNUM = :PNO1 END-EXEC
* EXEC SQL OPEN Y;
CALL "SUB8" USING SQLCODE
MOVE SQLCODE TO SQL-COD
MOVE 0 TO i
PERFORM P49 UNTIL i > 4
if (EMPNO1 = "E2" AND PCITY = "Vienna") then
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0127','pass','MCO') END-EXEC
CALL "SUB9" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " *** pass *** "
else
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0127','fail','MCO') END-EXEC
ADD 1 TO errcnt
CALL "SUB10" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " dml028.sco *** fail *** "
END-IF
DISPLAY "================================================"
DISPLAY " "
* EXEC SQL COMMIT WORK;
CALL "SUB11" USING SQLCODE
MOVE SQLCODE TO SQL-COD
******************** END TEST0127 *******************
******************** BEGIN TEST0128 *******************
DISPLAY " TEST0128 "
DISPLAY " OPEN three cursors at same time to check. "
DISPLAY "reference X3.135-1989 section 8.8 General Rules"
DISPLAY " - - - - - - - - - - - - - - - - - - -"
DISPLAY " *** EXEC SQL DECLARE B CURSOR "
DISPLAY " *** FOR SELECT EMPNUM,PNUM"
DISPLAY " *** FROM WORKS "
DISPLAY " *** ORDER BY EMPNUM ASC,PNUM ASC "
* EXEC SQL DECLARE B CURSOR
* FOR SELECT EMPNUM,PNUM
* FROM WORKS
* ORDER BY EMPNUM ASC,PNUM ASC END-EXEC
* EXEC SQL DECLARE D CURSOR
* FOR SELECT CITY
* FROM STAFF
* WHERE EMPNUM = :EMPNO1 END-EXEC
* EXEC SQL DECLARE E CURSOR
* FOR SELECT CITY
* FROM PROJ
* WHERE PNUM = :PNO1 END-EXEC
* EXEC SQL OPEN B;
CALL "SUB12" USING SQLCODE
MOVE SQLCODE TO SQL-COD
MOVE 0 TO i
PERFORM P48 UNTIL i > 4
if (SCITY = "Deale" AND PNO1 = "P5") then
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0128','pass','MCO') END-EXEC
CALL "SUB13" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " *** pass *** "
else
* EXEC SQL INSERT INTO TESTREPORT
* VALUES('0128','fail','MCO') END-EXEC
ADD 1 TO errcnt
CALL "SUB14" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " dml028.sco *** fail *** "
END-IF
DISPLAY "================================================"
DISPLAY " "
* EXEC SQL COMMIT WORK;
CALL "SUB15" USING SQLCODE
MOVE SQLCODE TO SQL-COD
******************** END TEST0128 *******************
**** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0
STOP RUN.
* **** Procedures for PERFORM statements
P50.
* EXEC SQL FETCH X INTO :EMPNO1,:HOURS1;
CALL "SUB16" USING SQLCODE EMPNO1 HOURS1
MOVE SQLCODE TO SQL-COD
if (SQLCODE = 0) then
DISPLAY " EMPNO1=", EMPNO1 " and HOURS1=",
HOURS1 " "
END-IF
ADD 1 TO i
.
P49.
* EXEC SQL FETCH Y INTO :EMPNO1,:PNO1;
CALL "SUB17" USING SQLCODE EMPNO1 PNO1
MOVE SQLCODE TO SQL-COD
DISPLAY " EMPNO1=", EMPNO1 " and PNO1=", PNO1 " "
* EXEC SQL OPEN Z;
CALL "SUB18" USING SQLCODE EMPNO1
MOVE SQLCODE TO SQL-COD
* EXEC SQL FETCH Z INTO :SCITY;
CALL "SUB19" USING SQLCODE SCITY
MOVE SQLCODE TO SQL-COD
* EXEC SQL CLOSE Z;
CALL "SUB20" USING SQLCODE
MOVE SQLCODE TO SQL-COD
* EXEC SQL OPEN A;
CALL "SUB21" USING SQLCODE PNO1
MOVE SQLCODE TO SQL-COD
* EXEC SQL FETCH A INTO :PCITY;
CALL "SUB22" USING SQLCODE PCITY
MOVE SQLCODE TO SQL-COD
* EXEC SQL CLOSE A;
CALL "SUB23" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " STAFF.CITY = ", SCITY ", PROJ.CITY =", PCITY " "
ADD 1 TO i
.
P48.
* EXEC SQL FETCH B INTO :EMPNO1,:PNO1;
CALL "SUB24" USING SQLCODE EMPNO1 PNO1
MOVE SQLCODE TO SQL-COD
DISPLAY " EMPNO1=", EMPNO1 " and PNO1=", PNO1 " "
* EXEC SQL OPEN D;
CALL "SUB25" USING SQLCODE EMPNO1
MOVE SQLCODE TO SQL-COD
* EXEC SQL OPEN E;
CALL "SUB26" USING SQLCODE PNO1
MOVE SQLCODE TO SQL-COD
* EXEC SQL FETCH D INTO :SCITY;
CALL "SUB27" USING SQLCODE SCITY
MOVE SQLCODE TO SQL-COD
* EXEC SQL FETCH E INTO :PCITY;
CALL "SUB28" USING SQLCODE PCITY
MOVE SQLCODE TO SQL-COD
* EXEC SQL CLOSE D;
CALL "SUB29" USING SQLCODE
MOVE SQLCODE TO SQL-COD
* EXEC SQL CLOSE E;
CALL "SUB30" USING SQLCODE
MOVE SQLCODE TO SQL-COD
DISPLAY " STAFF.CITY = ", SCITY ", PROJ.CITY =", PCITY " "
ADD 1 TO i
.
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|