* Standard COBOL (file "XTS727.SCO") calling SQL * procedures in file "XTS727.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 * * XTS727.SCO * WRITTEN BY: Vassilis Kogakis * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * Flagging - FULL SQL - <explicit table> in <query expression> * * REFERENCES * 7.10 -- <query expression> * 7.10 SR.2 * 7.10 SR.5b * 7.10 LR.1b -- Intermediate SQL restriction which prohibits * the use of <explicit table> in a <simple * table> in a <query expression> * F#37 -- Intermediate SQL Flagging. * * DATE LAST ALTERED 09/02/96 Alpha Release V1.0 * * Cleanups and fixes by V. Kogakis 09/02/96 * * Rewritten by V. Kogakis on 09/02/96 * * Revised by DWF 1996-02-14 * Fixed char string lengths * Fixed refs to non-existent columns ****************************************************************
*initialise host variables MOVE"xxxxxxxxxx"TO c_ch1 MOVE"xxxxxxxxxx"TO c_ch2 MOVE 0 TO c_num1 MOVE 0 TO c_num2 MOVE 0 TO coun
*Insert into TEST6840C all rows from table CL_STANDARD DISPLAY"INSERT INTO TEST6840C" DISPLAY"TABLE CL_STANDARD;" * EXEC SQL INSERT INTO TEST6840C * TABLE CL_STANDARD; CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"SELECT COUNT(*) INTO :coun FROM TEST6840C;" * EXEC SQL SELECT COUNT(*) INTO :coun FROM TEST6840C; CALL"SUB4"USING SQLCODE SQLSTATE coun MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"Coun should be 5; its value is: ", coun if (coun NOT = 5) then MOVE 0 TO flag END-IF DISPLAY" "
*now check if all rows were inserted correctly *First row DISPLAY"SELECT NUM_C1,CH_C1,NUM_C2,CH_C2" DISPLAY"INTO :c_num1,:c_ch1,:c_num2,:c_ch2" DISPLAY"FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1000;" * EXEC SQL SELECT NUM_C1,CH_C1,NUM_C2,CH_C2 * INTO :c_num1,:c_ch1,:c_num2,:c_ch2 * FROM TEST6840C * WHERE NUM_C1 = 1000; CALL"SUB5"USING SQLCODE SQLSTATE c_num1 c_ch1 c_num2
c_ch2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *check results returned by the <query specification>* DISPLAY"NUM_C1 should be 1000; it is : ", c_num1 DISPLAY"CH_C1 should be NICKOS; it is : ", c_ch1 DISPLAY"NUM_C2 should be 4000; it is : ", c_num2 DISPLAY"CH_C2 should be ATHENS; it is : ", c_ch2 if (c_ch1 NOT = "NICKOS"OR c_ch2 NOT = "ATHENS") then MOVE 0 TO flag END-IF if (c_num2 NOT = 4000 OR c_num1 NOT = 1000) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxx"TO c_ch1 MOVE"xxxxxxxxxx"TO c_ch2 MOVE 0 TO c_num1 MOVE 0 TO c_num2
*Second row DISPLAY"SELECT NUM_C1,CH_C1,NUM_C2,CH_C2" DISPLAY"INTO :c_num1,:c_ch1,:c_num2,:c_ch2" DISPLAY"FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1001;" * EXEC SQL SELECT NUM_C1,CH_C1,NUM_C2,CH_C2 * INTO :c_num1,:c_ch1,:c_num2,:c_ch2 * FROM TEST6840C * WHERE NUM_C1 = 1001; CALL"SUB6"USING SQLCODE SQLSTATE c_num1 c_ch1 c_num2
c_ch2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *check results returned by the <query specification>* DISPLAY"NUM_C1 should be 1001; it is : ", c_num1 DISPLAY"CH_C1 should be MARIA; it is : ", c_ch1 DISPLAY"NUM_C2 should be 4001; it is : ", c_num2 DISPLAY"CH_C2 should be RHODES; it is : ", c_ch2 if (c_ch1 NOT = "MARIA"OR c_ch2 NOT = "RHODES") then MOVE 0 TO flag END-IF if (c_num2 NOT = 4001 OR c_num1 NOT = 1001) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxx"TO c_ch1 MOVE"xxxxxxxxxx"TO c_ch2 MOVE 0 TO c_num1 MOVE 0 TO c_num2
*Third row DISPLAY"SELECT NUM_C1,CH_C1,NUM_C2,CH_C2" DISPLAY"INTO :c_num1,:c_ch1,:c_num2,:c_ch2" DISPLAY"FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1002;" * EXEC SQL SELECT NUM_C1,CH_C1,NUM_C2,CH_C2 * INTO :c_num1,:c_ch1,:c_num2,:c_ch2 * FROM TEST6840C * WHERE NUM_C1 = 1002; CALL"SUB7"USING SQLCODE SQLSTATE c_num1 c_ch1 c_num2
c_ch2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *check results returned by the <query specification>* DISPLAY"NUM_C1 should be 1002; it is : ", c_num1 DISPLAY"CH_C1 should be MAKIS; it is : ", c_ch1 DISPLAY"NUM_C2 should be 4002; it is : ", c_num2 DISPLAY"CH_C2 should be HANIA; it is : ", c_ch2 if (c_ch1 NOT = "MAKIS"OR c_ch2 NOT = "HANIA") then MOVE 0 TO flag END-IF if (c_num2 NOT = 4002 OR c_num1 NOT = 1002) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxx"TO c_ch1 MOVE"xxxxxxxxxx"TO c_ch2 MOVE 0 TO c_num1 MOVE 0 TO c_num2
*Forth row DISPLAY"SELECT NUM_C1,CH_C1,NUM_C2,CH_C2" DISPLAY"INTO :c_num1,:c_ch1,:c_num2,:c_ch2" DISPLAY"FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1003;" * EXEC SQL SELECT NUM_C1,CH_C1,NUM_C2,CH_C2 * INTO :c_num1,:c_ch1,:c_num2,:c_ch2 * FROM TEST6840C * WHERE NUM_C1 = 1003; CALL"SUB8"USING SQLCODE SQLSTATE c_num1 c_ch1 c_num2
c_ch2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *check results returned by the <query specification>* DISPLAY"NUM_C1 should be 1003; it is : ", c_num1 DISPLAY"CH_C1 should be GEORGE; it is : ", c_ch1 DISPLAY"NUM_C2 should be 4003; it is : ", c_num2 DISPLAY"CH_C2 should be ARTA; it is : ", c_ch2 if (c_ch1 NOT = "GEORGE"OR c_ch2 NOT = "ARTA") then MOVE 0 TO flag END-IF if (c_num2 NOT = 4003 OR c_num1 NOT = 1003) then MOVE 0 TO flag END-IF DISPLAY" "
*initialise host variables MOVE"xxxxxxxxxx"TO c_ch1 MOVE"xxxxxxxxxx"TO c_ch2 MOVE 0 TO c_num1 MOVE 0 TO c_num2
*Fifth row DISPLAY"SELECT NUM_C1,CH_C1,NUM_C2,CH_C2" DISPLAY"INTO :c_num1,:c_ch1,:c_num2,:c_ch2" DISPLAY"FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1004;" * EXEC SQL SELECT NUM_C1,CH_C1,NUM_C2,CH_C2 * INTO :c_num1,:c_ch1,:c_num2,:c_ch2 * FROM TEST6840C * WHERE NUM_C1 = 1004; CALL"SUB9"USING SQLCODE SQLSTATE c_num1 c_ch1 c_num2
c_ch2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *check results returned by the <query specification>* DISPLAY"NUM_C1 should be 1004; it is : ", c_num1 DISPLAY"CH_C1 should be MORRIS; it is : ", c_ch1 DISPLAY"NUM_C2 should be 4004; it is : ", c_num2 DISPLAY"CH_C2 should be PARGA; it is : ", c_ch2 if (c_ch1 NOT = "MORRIS"OR c_ch2 NOT = "PARGA") then MOVE 0 TO flag END-IF if (c_num2 NOT = 4004 OR c_num1 NOT = 1004) then MOVE 0 TO flag END-IF DISPLAY" "
*restore table CL_STANDARD in its original state DISPLAY"ROLLBACK WORK;" * EXEC SQL ROLLBACK WORK; CALL"SUB10"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*record results
if ( flag = 1 ) then DISPLAY" xts727.mco *** pass *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7027','pass','MCO'); CALL"SUB11"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD DISPLAY"Intermediate SQL extension" DISPLAY"Explicit table in " DISPLAY"executed successfully." DISPLAY"Vendor must demonstrate Intermediate Flagger
- " WARNING" else DISPLAY" xts727.mco *** NOGO *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7027','NOGO','MCO'); CALL"SUB12"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD DISPLAY"Vendor does not support fully " DISPLAY"Intermediate SQL extension " DISPLAY"Support explicit table in query expression is
- " not required" END-IF DISPLAY"========================================"
* EXEC SQL COMMIT WORK; CALL"SUB13"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST7027 ********************
**** 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.16 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.