* Standard COBOL (file "XTS759.SCO") calling SQL * procedures in file "XTS759.MCO".
*Copyright 1995 National Computing Centre Limited *and Computer Logic R&D S.A *on behalf of the CTS5 SQL2 Project. *All rights reserved. *The CTS5 SQL2 Project is sponsored by the European Community. * *The National Computing Centre Limited and Computer Logic R&D *have given permission to NIST to distribute this program *over the World Wide Web in order to promote SQL standards. *DISCLAIMER: *This program was reviewed by employees of NIST for *conformance to the SQL standards. *NIST assumes no responsibility for any party's use of *this program.
**************************************************************** * * COMMENT SECTION * * SQL VALIDATION TEST SUITE V6.0 * * XTS759.SCO * WRITTEN BY: Nickos Backalidis * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * *Scrolled cursor on grouped view,FETCH RELATIVE,FIRST,ABSOLUTE * * REFERENCES * 13.1 -- <Declare cursor> * 13.3 -- <Fetch statement> * 13.3 GR.5bi * F#3 -- Basic schema manipulation * F#24 -- Keyword relaxations * F#43 -- Scrolled cursors * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 15/12/95 * Print timestamp * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * * QA STATUS : QA CHECK * * Revised by DWF 1996-02-20 * Removed status checks after cursor definition * Added order by clause to enforce ordering that was assumed * Fixed relative fetch to get expected results * Added printouts * Fixed string lengths * Removed coding rule violations ****************************************************************
*create a grouped view under the current schema DISPLAY"CREATE VIEW VA759 (WORKERS,CITCOUN)" DISPLAY"AS SELECT EMPNAME,COUNT(CITY)" DISPLAY"FROM CTS1.STAFFc" DISPLAY"GROUP BY EMPNAME;" * EXEC SQL CREATE VIEW VA759 (WORKERS,CITCOUN) * AS SELECT EMPNAME,COUNT(CITY) * FROM CTS1.STAFFc * GROUP BY EMPNAME; CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE ACURS SCROLL CURSOR FOR SELECT
- " WORKERS,CITCOUN" DISPLAY"FROM VA759 ORDER BY WORKERS;" * EXEC SQL DECLARE ACURS SCROLL CURSOR FOR SELECT * WORKERS,CITCOUN * FROM VA759 ORDER BY WORKERS END-EXEC
DISPLAY"OPEN ACURS;" * EXEC SQL OPEN ACURS; CALL"SUB5"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxxxxxxxxxxxx"TO col1 MOVE 3 TO rowptr DISPLAY"rowptr = 3;" MOVE 0 TO col2
*now fetch the third row of the grouped view DISPLAY"FETCH ABSOLUTE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH ABSOLUTE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB6"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Carmen; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Carmen"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxxxxxxxxxxxx"TO col1 MOVE 0 TO col2
*now fetch the first row of the grouped view DISPLAY"FETCH FIRST FROM ACURS INTO :col1,:col2;" * EXEC SQL FETCH FIRST FROM ACURS INTO :col1,:col2; CALL"SUB7"USING SQLCODE SQLSTATE col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Alice; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Alice"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxxxxxxxxxxxx"TO col1 MOVE 0 TO rowptr DISPLAY"rowptr = 0;" MOVE 0 TO col2
*now fetch again the first row of the grouped view DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB8"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Alice; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Alice"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxxxxxxxxxxxx"TO col1 MOVE 5 TO rowptr DISPLAY"rowptr = 5;" MOVE 0 TO col2
*now retrieve the last row of the grouped view DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB9"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Tom; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Tom"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
*now retrieve the rest of the view rows in reverse order DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB10"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Kingdom; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Kingdom"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB11"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Don; its value is ", col1 DISPLAY"CITCOUN should be 2; its value is ", col2 if (col1 NOT = "Don"OR col2 NOT = 2) then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB12"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Carmen; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Carmen"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB13"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Betty; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Betty"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
*now fetch first and final row DISPLAY"FETCH RELATIVE :rowptr FROM ACURS INTO
- " :col1,:col2;" * EXEC SQL FETCH RELATIVE :rowptr FROM ACURS INTO :col1,:col2 * ; CALL"SUB14"USING SQLCODE SQLSTATE rowptr col1 col2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"WORKERS1 should be Alice; its value is ", col1 DISPLAY"CITCOUN should be 1; its value is ", col2 if (col1 NOT = "Alice"OR col2 NOT = 1) then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"CLOSE ACURS;" * EXEC SQL CLOSE ACURS; CALL"SUB15"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*record results if ( flag = 1 ) then DISPLAY" xts759.mco *** pass *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7059','pass','MCO'); CALL"SUB19"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD else DISPLAY" xts759.mco *** fail *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7059','fail','MCO'); CALL"SUB20"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
DISPLAY"========================================"
* EXEC SQL COMMIT WORK; CALL"SUB21"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST7059 ********************
**** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0 STOPRUN.
* **** Procedures for PERFORM statements
*Test SQLCODE and SQLSTATE for normal completion.
CHCKOK. DISPLAY"SQLCODE should be 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 00000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODE NOT = 0 OR NORMSQ NOT = "00000") then MOVE 0 TO flag END-IF if (NORMSQ = "00000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF
.
NOSUBCLASS.
*This routine replaces valid implementation-defined *subclasses with 000. This replacement equates valid *implementation-defined subclasses with the 000 value *expected by the test case; otherwise the test will fail. *After calling NOSUBCLASS, NORMSQ will be tested * SQLSTATE will be printed.
MOVE SQLSTATE TO NORMSQ
MOVE 3 TO norm1 *subclass begins in position 3 of char array NORMSQ *valid subclass begins with 5-9, I-Z, end of ALPNUM table PERFORMVARYING norm2 FROM 14 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
*Quit if NORMSQ is unchanged. Subclass is not impl.-def. *Changed NORMSQ means implementation-defined subclass, *so proceed to zero it out, if valid (0-9,A-Z) if (NORMSQ = SQLSTATE) then GOTO EXIT-NOSUBCLASS END-IF
MOVE 4 TO norm1 *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORMVARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
MOVE 5 TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
*implementation-defined subclasses are allowed for warnings *(class = 01). These equate to successful completion *SQLSTATE values of 00000. *Reference SQL-92 4.28 SQL-transactions, paragraph 2
if (NORMSQX(1) = "0"AND NORMSQX(2) = "1") then MOVE"0"TO NORMSQX(2) END-IF
.
EXIT-NOSUBCLASS. EXIT.
¤ 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.0.23Bemerkung:
(vorverarbeitet)
¤
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.