* Standard COBOL (file "XTS742.SCO") calling SQL * procedures in file "XTS742.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 * * XTS742.SCO TEST7042 * WRITTEN BY: Nickos Backalidis * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * COUNT ALL <literal> * * REFERENCES * 6.5 -- <set function specification> * 6.5 GR.1b * 5.3 -- <Literal> * F#44 -- Intermediate set function * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 08/12/95 * Print timestamp * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * * QA STATUS : FC * * Revised by DWF 1996-02-09 * Harmonized printouts with statements * Fixed expected results * Fixed coding rules violations ****************************************************************
*Initialise host variables MOVE 0 TO counst MOVE 0 TO cound MOVE 0 TO counum MOVE 0 TO cnall MOVE 0 TO cncol1 MOVE 0 TO cncol2
DISPLAY"SELECT COUNT(ALL 115.5),COUNT(ALL 'ATHINA'),
- " COUNT(ALL 255)," DISPLAY"COUNT(*) INTO :counst, :cound, :counum, :cnall
- " FROM CL_DATA_TYPE; " * EXEC SQL SELECT COUNT(ALL 115.5), COUNT(ALL 'ATHINA'), * COUNT(ALL 255), * COUNT(*) INTO :counst,:cound,:counum,:cnall FROM * CL_DATA_TYPE; CALL"SUB3"USING SQLCODE SQLSTATE counst cound counum
cnall MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"counst should be 6; its value is ", counst, " " DISPLAY"cound should be 6; its value is ", cound, " " DISPLAY"counum should be 6; its value is ", counum, " " DISPLAY"cnall should be 6; its value is ", cnall, " " if (counst NOT = 6 OR cound NOT = 6 OR counum NOT
= 6 OR cnall NOT = 6) then MOVE 0 TO flag END-IF DISPLAY" "
*insert two more rows in the table CL_DATA_TYPE DISPLAY"INSERT INTO CTS1.CL_DATA_TYPE
- " VALUES(NULL,55,225,10);" * EXEC SQL INSERT INTO CTS1.CL_DATA_TYPE * VALUES(NULL,55,225,10); CALL"SUB4"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO CTS1.CL_DATA_TYPE
- " VALUES(NULL,15,140,NULL);" * EXEC SQL INSERT INTO CTS1.CL_DATA_TYPE * VALUES(NULL,15,140,NULL); CALL"SUB5"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Initialise host variables MOVE 0 TO counst MOVE 0 TO cound MOVE 0 TO counum MOVE 0 TO cnall MOVE 0 TO cncol1 MOVE 0 TO cncol2
DISPLAY"SELECT COUNT(*),COUNT(ALL 119),COUNT(ALL
- " 'GIORGOS'),COUNT(CL_CHAR)" DISPLAY"COUNT(CL_REAL) INTO : cnall, : counum, :counst,
- " :cncol1," DISPLAY":cncol2 FROM CL_DATA_TYPE;" * EXEC SQL SELECT COUNT(*),COUNT(ALL 119), COUNT(ALL * 'GIORGOS') ,COUNT(CL_CHAR), * COUNT(CL_REAL) INTO :cnall, :counum, :counst, :cncol1, * :cncol2 * FROM CL_DATA_TYPE; CALL"SUB6"USING SQLCODE SQLSTATE cnall counum counst
cncol1 cncol2 MOVE SQLCODE TO SQL-COD DISPLAY"cnall should be 8; its value is ", cnall, " " DISPLAY"counum should be 8; its value is ", counum, " " DISPLAY"counst should be 8; its value is ", counst, " " DISPLAY"cncol1 should be 6; its value is ", cncol1, " " DISPLAY"cncol2 should be 7; its value is ", cncol2, " " DISPLAY"SQLSTATE should be 01003; its value is ", SQLSTATE if (counst NOT = 8 OR counum NOT = 8 OR cnall NOT
= 8) then MOVE 0 TO flag END-IF if (cncol1 NOT = 6 OR cncol2 NOT = 7) then MOVE 0 TO flag END-IF if (SQLSTATE NOT = "01003") then MOVE 0 TO flag END-IF DISPLAY" "
*insert one row with null values in the table DISPLAY"INSERT INTO CTS1.CL_DATA_TYPE
- " VALUES(NULL,0,0,NULL);" * EXEC SQL INSERT INTO CTS1.CL_DATA_TYPE * VALUES(NULL,0,0,NULL); CALL"SUB7"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Initialise host variables MOVE 0 TO counst MOVE 0 TO cound MOVE 0 TO counum MOVE 0 TO cnall MOVE 0 TO cncol1 MOVE 0 TO cncol2
DISPLAY"SELECT COUNT(*),COUNT(ALL
- " 1000),COUNT(ALL'STEFOS'),COUNT(CL_CHAR)" DISPLAY"COUNT(CL_REAL) INTO :cnall, :counum, :counst,
- " :cncol1, :cncol2" DISPLAY"FROM CL_DATA_TYPE;" * EXEC SQL SELECT COUNT(*), COUNT(ALL 1000), COUNT(ALL * 'STEFOS'),COUNT(CL_CHAR), * COUNT(CL_REAL) INTO : cnall, :counum, :counst, :cncol1, * :cncol2 * FROM CL_DATA_TYPE; CALL"SUB8"USING SQLCODE SQLSTATE cnall counum counst
cncol1 cncol2 MOVE SQLCODE TO SQL-COD DISPLAY"counst should be 9; its value is ", counst, " " DISPLAY"counum should be 9; its value is ", counum, " " DISPLAY"cnall should be 9; its value is ", cnall, " " DISPLAY"cncol1 should be 6; its value is ", cncol1, " " DISPLAY"cncol2 should be 7; its value is ", cncol2, " " DISPLAY"SQLSTATE should be 01003; its value is ", SQLSTATE if (counst NOT = 9 OR counum NOT = 9 OR cnall NOT
= 9) then MOVE 0 TO flag END-IF if (cncol1 NOT = 6 OR cncol2 NOT = 7) then MOVE 0 TO flag END-IF if (SQLSTATE NOT = "01003") then MOVE 0 TO flag END-IF DISPLAY" "
******************** END TEST7042 ********************
**** 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.
¤ Dauer der Verarbeitung: 0.4 Sekunden
(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.