* Standard COBOL (file "XTS701.SCO") calling SQL * procedures in file "XTS701.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 * * XTS701.SCO * WRITTEN BY: Manolis Megaloikonomou * REVIEWED BY: Nickos Backalidis * * This programs tests * a). compound character literal in <comparison predicate> * b). compound character literal as inserted value * c). compound character literal in a <select list> * *--------------------------------------------------------------- * TEST7004 * * Compound char. literal in <comparison predicate> * References: * 5.3 FT.4 * 5.3 SR.1 * 5.3 SR.4 * 5.3 GR.1 * 8.2 GR.1 * 8.2 GR.3 * 8.2 GR.7 * 5.3 LR.2.d * 6.5 FT.1 --COUNT set function * 6.5 SR.2 * F#27 Compound character literals *--------------------------------------------------------------- * TEST7005 * * Compound character literal as inserted value * References: * 5.3 SR.1 * 5.3 SR.4 * 5.3 GR.1 * 5.3 LR.2.d * 13.8 FT.1 <insert statement> * 7.2 FT.1 <table value constructor> * 7.1 FT.3 <row value constructor element> * 6.11 FT.1 <value expression> * F#27 Compound character literals * *--------------------------------------------------------------- * TEST7006 * Compound character literal in a <select list> * References: * 5.3 SR.1 * 5.3 SR.4 * 5.3 GR.1 * 5.3 LR.2.d * 7.9 FT.1 <query specification> * 6.11 FT.1 <value expression> * F#27 Compound character literal * *--------------------------------------------------------------- * * DATE LAST ALTERED 15/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 01/12/95: * Initialization of the ALPNUM string * * QA Status: QA check * *Repaired by DWF 1/18/96 * Fixed checks for wrong SQLCODE * Fixed references to non-existent rows * Fixed wrong initializations * Fixed wrong declarations * Removed extraneous code and variables * Moved initializations * Output formatting * Removed checks of invalid results ****************************************************************
MOVE"CTS1 "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx * EXEC SQL SELECT USER INTO :uidx FROM CTS1.ECCO; CALL"SUB1"USING SQLCODE SQLSTATE uidx MOVE SQLCODE TO SQL-COD * EXEC SQL ROLLBACK WORK; CALL"SUB2"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD
if (uid NOT = uidx) then DISPLAY"ERROR: User ", uid, " expected. User ", uidx, "
- " connected" STOPRUN END-IF MOVE 0 TO errcnt
DISPLAY "SQL Test Suite, V6.0, Module COBOL, xts701.sco" DISPLAY "59-byte ID" DISPLAY"TEd Version #" *date_time print ACCEPT TO-DAY FROMDATE ACCEPT THE-TIME FROMTIME DISPLAY"Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME
*Set up long strings for comparison statements
MOVE"This is the first fragment of a compound"TO part1 MOVE" character literal, and this is the second part."TO
part2 MOVE"This is a compound character literal, in"TO part3 MOVE"This is a compound character literal, in"TO part3x MOVE" the second table row."TO part4 MOVE" the third table row."TO part6 MOVE"First fragment of a compound character l"TO part7 MOVE"iteral, and second part."TO part8 MOVE"This is the first fragment of a compound"TO part9 MOVE" character literal, this is the second, "TO part10 MOVE"and this is the third part."TO part11
MOVE partv TO str1
MOVE partw TO str2
MOVE partx TO str3
MOVE party TO str4
MOVE partz TO str5
MOVE"Compound literal."TO str6
******************** BEGIN TEST7004 *******************
*Insert compound literals into table T4 DISPLAY"INSERT INTO T4 " DISPLAY"VALUES('This is the first compound character " DISPLAY"literal.',1,NULL,NULL);" * EXEC SQL INSERT INTO T4 * VALUES('This is the first compound character * literal.',1,NULL,NULL); CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T4 " DISPLAY"VALUES('Second character literal.',2,NULL,NULL);" * EXEC SQL INSERT INTO T4 * VALUES('Second character literal.',2,NULL,NULL); CALL"SUB4"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T4 " DISPLAY"VALUES('Third character literal.',3,NULL,NULL);" * EXEC SQL INSERT INTO T4 * VALUES('Third character literal.',3,NULL,NULL); CALL"SUB5"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Attempt to return row that is not in table DISPLAY"SELECT NUM6 INTO :num FROM T4" DISPLAY"WHERE STR110 = 'This is the compound '" DISPLAY"'character literal.';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE STR110 = 'This is the compound ' * 'character literal.'; CALL"SUB6"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD *check for no data condition 02000 *That should generate a no data condition which is SQLSTATE 0200 DISPLAY"SQLCODE should be 100; its value is ", SQL-COD if (SQLCODE NOT = 100) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
*check second and third rows inserted correctly MOVE 0 TO COUN DISPLAY"SELECT COUNT(*) INTO :COUN FROM T4" DISPLAY"WHERE STR110 <> 'This is the first compound '" DISPLAY"'character literal.';" * EXEC SQL SELECT COUNT(*) * INTO :COUN * FROM T4 * WHERE STR110 <> 'This is the first compound ' * 'character literal.'; CALL"SUB7"USING SQLCODE SQLSTATE COUN MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"Coun should be 2; its value is ", COUN if (COUN NOT = 2) then MOVE 0 TO flag END-IF DISPLAY" "
MOVE 0 TO num DISPLAY"SELECT NUM6 INTO :num FROM T4 WHERE NUM6 = 2" DISPLAY"AND STR110 <= 'Second character '--Comments here" DISPLAY"'literal.';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE NUM6 = 2 AND STR110 <= 'Second character * '--Comments here * 'literal.'; CALL"SUB8"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"num should be 2; its value is ", num if (num NOT = 2) then MOVE 0 TO flag END-IF DISPLAY" "
*attempt to return values from row which does not exist DISPLAY"SELECT NUM6 INTO :num FROM T4" DISPLAY"WHERE STR110 = 'Third character
- " literal.'--Comments here" DISPLAY"'second fragment'" DISPLAY"'third fragment.';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE STR110 = 'Third character literal.'--Comments here * 'second fragment' * 'third fragment.'; CALL"SUB9"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD *That should generate a no data condition *which is SQLSTATE 02000 DISPLAY"SQLCODE should be 100; its value is ", SQL-COD if (SQLCODE NOT = 100) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"SELECT NUM6 INTO :num FROM T4 WHERE STR110 =
- " 'First fragment'" DISPLAY"'another fragment'--Comments" DISPLAY"'Second character literal.'--Comments here" DISPLAY"'fourth fragment.';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE STR110 = 'First fragment' * 'another fragment'--Comments * 'Second character literal.'--Comments here * 'fourth fragment.'; CALL"SUB10"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD *That should generate a no data condition *which is SQLSTATE 02000 DISPLAY"SQLCODE should be 100; its value is ", SQL-COD if (SQLCODE NOT = 100) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
MOVE 0 TO num DISPLAY"SELECT NUM6 INTO :num FROM T4 WHERE STR110 <=
- " 'Second '" DISPLAY"'chara'--Comments" DISPLAY"'cter liter'--Comments here" DISPLAY"'al.'" DISPLAY"' ';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE STR110 <= 'Second ' * 'chara'--Comments * 'cter liter'--Comments here * 'al.' * ' '; CALL"SUB11"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"num should be 2; its value is ", num if (num NOT = 2) then MOVE 0 TO flag END-IF DISPLAY" "
MOVE 99 TO num1 MOVE 99 TO num
DISPLAY"SELECT COUNT(*) INTO :num FROM T4 WHERE STR110 <" DISPLAY"'An indifferent'--Comments" DISPLAY"' charac'" DISPLAY"'ter literal.';" * EXEC SQL SELECT COUNT(*) * INTO :num * FROM T4 * WHERE STR110 < 'An indifferent'--Comments * ' charac' * 'ter literal.'; CALL"SUB12"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"SELECT COUNT(*) INTO :num1 FROM T4 WHERE STR110
- " >=" DISPLAY"'An indifferent'--Comments" DISPLAY"' charac'" DISPLAY"'ter literal.';" * EXEC SQL SELECT COUNT(*) * INTO :num1 * FROM T4 * WHERE STR110 >= 'An indifferent'--Comments * ' charac' * 'ter literal.'; CALL"SUB13"USING SQLCODE SQLSTATE num1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" " COMPUTE total = num + num1 DISPLAY"num + num1 should be 3, " DISPLAY"their values are: num = ", num, ", num1 = ", num1 if (total NOT = 3) then MOVE 0 TO flag END-IF
MOVE 0 TO num DISPLAY"SELECT NUM6 INTO :num FROM T4 WHERE STR110 =
- " 'Second '" DISPLAY"'chara'--Comments" DISPLAY"'cter liter'--Comments here" DISPLAY"'al.'" DISPLAY"' '--Comments" DISPLAY"' ';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE STR110 = 'Second ' * 'chara'--Comments * 'cter liter'--Comments here * 'al.' * ' '--Comments * ' '; CALL"SUB14"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD PERFORM CHCKOK if (num NOT = 2) then MOVE 0 TO flag END-IF DISPLAY"num should be 2; its value is ", num DISPLAY" "
DISPLAY"SELECT NUM6 INTO :num FROM T4" DISPLAY"WHERE NUM6 = 2 AND STR110 < 'Second '" DISPLAY"'chara'--Comments" DISPLAY"'cter literal.';" * EXEC SQL SELECT NUM6 * INTO :num * FROM T4 * WHERE NUM6 = 2 AND STR110 < 'Second ' * 'chara'--Comments * 'cter literal.'; CALL"SUB15"USING SQLCODE SQLSTATE num MOVE SQLCODE TO SQL-COD
*That should generate a no data condition *which is SQLSTATE 02000 DISPLAY"SQLCODE should be 100; its value is ", SQL-COD if (SQLCODE NOT = 100) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"INSERT INTO T4 " DISPLAY"VALUES('This is the first fragment of a compound" DISPLAY"character literal,' --Comments" DISPLAY"' and this is the second part.',11,NULL,'Compound
- " ' " DISPLAY" " DISPLAY" --Comments " DISPLAY" " DISPLAY" 'literal.');" * EXEC SQL INSERT INTO T4 * VALUES('This is the first fragment of a compound * character literal,' --Comments * ' and this is the second part.',11,NULL,'Compound ' * * --Comments * * 'literal.'); CALL"SUB20"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T4 " DISPLAY"VALUES('This is a comp'" DISPLAY"'ound character literal,'" DISPLAY"' in the second table row.',12,NULL,NULL);" * EXEC SQL INSERT INTO T4 * VALUES('This is a comp' * 'ound character literal,' * ' in the second table row.',12,NULL,NULL); CALL"SUB21"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"SELECT STR110, COL4 INTO :CCL1, :CCL2 FROM T4
- " WHERE NUM6 = 11;" * EXEC SQL SELECT STR110, COL4 INTO :CCL1, :CCL2 FROM T4 * WHERE NUM6 = 11; CALL"SUB23"USING SQLCODE SQLSTATE CCL1 CCL2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"CCL1 should be ", str1, "; its value is ", CCL1 DISPLAY"CCL2 should be ", str6, "; its value is ", CCL2 if (CCL1 NOT = str1 OR CCL2 NOT = str6) then MOVE 0 TO flag END-IF DISPLAY" "
MOVE"xxxxxxxxxxxxxx"TO CCL1 DISPLAY"SELECT STR110 INTO :CCL1 FROM T4 WHERE NUM6 = 12;" * EXEC SQL SELECT STR110 INTO :CCL1 FROM T4 WHERE NUM6 = 12 * ; CALL"SUB24"USING SQLCODE SQLSTATE CCL1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK if (CCL1 NOT = str2) then MOVE 0 TO flag END-IF DISPLAY"CCL1 should be ", str2, "; its value is ", CCL1 DISPLAY" "
MOVE"xxxxxxxxxxxxxx"TO CCL1 DISPLAY"SELECT STR110 INTO :CCL1 FROM T4 WHERE NUM6 = 13;" * EXEC SQL SELECT STR110 * INTO :CCL1 * FROM T4 * WHERE NUM6 = 13; CALL"SUB25"USING SQLCODE SQLSTATE CCL1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"CCL1 should be ", str3, "; its value is ", CCL1 if (CCL1 NOT = str3) then MOVE 0 TO flag END-IF DISPLAY" "
*Select list contains only literals and is independent of table DISPLAY"SELECT 'First fragment of a compound character
- " literal, '" DISPLAY" --Comment1" DISPLAY" " DISPLAY" " DISPLAY" --Comment2" DISPLAY" 'and second part.'," DISPLAY"'This is the first fragment of a compound
- " character literal,'--..." DISPLAY" ' this is the second,'" DISPLAY" " DISPLAY" " DISPLAY" ' and this is the third part.'" DISPLAY" INTO :CCL1, :CCL2 FROM CTS1.ECCO;" * EXEC SQL SELECT 'First fragment of a compound character * literal, ' * --Comment1 * * * --Comment2 * 'and second part.', * 'This is the first fragment of a compound character * literal,'--... * ' this is the second,' * * * ' and this is the third part.' * INTO :CCL1, :CCL2 * FROM CTS1.ECCO; CALL"SUB30"USING SQLCODE SQLSTATE CCL1 CCL2 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"CCL1 should be ", str4, "; its value is ", CCL1 DISPLAY"CCL2 should be ", str5, "; its value is ", CCL2 if (CCL1 NOT = str4) then MOVE 0 TO flag END-IF if (CCL2 NOT = str5) then MOVE 0 TO flag END-IF DISPLAY" "
******************** END TEST7006 ********************
**** 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.
[ zur Elbe Produktseite wechseln0.18Quellennavigators
Analyse erneut starten
]