* Standard COBOL (file "DML170.SCO") calling SQL * procedures in file "DML170.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1996-05-09 Module COBOL LANGUAGE * 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. * * DML170.SCO * WRITTEN BY: David Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * This routine tests Intermediate SQL. * * REFERENCES * FIPS PUB 127-2 14.2 Intermediate SQL * ANSI SQL-1992 * ****************************************************************
DISPLAY"CREATE TABLE T0880 (" DISPLAY" C1 INT, C2 INT," DISPLAY" CONSTRAINT" DISPLAY"""It was the best of times; it was the worst of
- " times. THE END""" DISPLAY" PRIMARY KEY (C1, C2));" * EXEC SQL CREATE TABLE T0880 ( * C1 INT, C2 INT, * CONSTRAINT * "It was the best of times; it was the worst of times." * PRIMARY KEY (C1, C2)) * ; CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T0880 VALUES (0, 1);" * EXEC SQL INSERT INTO T0880 VALUES (0, 1); CALL"SUB5"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T0880 VALUES (1, 2);" * EXEC SQL INSERT INTO T0880 VALUES (1, 2); CALL"SUB6"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE" DISPLAY"""This change notice modifies Section 10 of FIPS
- " PUB 127-2.""" DISPLAY"CURSOR FOR" DISPLAY"SELECT C1 FROM T0880 ORDER BY C1;" * EXEC SQL DECLARE * "This change notice modifies Section 10 of FIPS PUB * - " 127-2." * CURSOR FOR * SELECT C1 FROM T0880 ORDER BY C1 END-EXEC
DISPLAY"OPEN" DISPLAY"""This change notice modifies Section 10 of FIPS
- " PUB 127-2."";" * EXEC SQL OPEN * "This change notice modifies Section 10 of FIPS PUB * " 127-2." CALL"SUB7"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE 666 TO int1 DISPLAY"FETCH" DISPLAY"""This change notice modifies Section 10 of FIPS
- " PUB 127-2.""" DISPLAY"INTO :int1;" * EXEC SQL FETCH * "This change notice modifies Section 10 of FIPS PUB * - " 127-2." * INTO :int1; CALL"SUB8"USING SQLCODE SQLSTATE int1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 0; its value is ", int1 if (int1 NOT = 0) then MOVE 0 TO flag END-IF
MOVE 666 TO int1 DISPLAY"FETCH" DISPLAY"""This change notice modifies Section 10 of FIPS
- " PUB 127-2.""" DISPLAY"INTO :int1;" * EXEC SQL FETCH * "This change notice modifies Section 10 of FIPS PUB * - " 127-2." * INTO :int1; CALL"SUB9"USING SQLCODE SQLSTATE int1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 1; its value is ", int1 if (int1 NOT = 1) then MOVE 0 TO flag END-IF
DISPLAY"CLOSE" DISPLAY"""This change notice modifies Section 10 of FIPS
- " PUB 127-2."";" * EXEC SQL CLOSE * "This change notice modifies Section 10 of FIPS PUB * - " 127-2."; CALL"SUB10"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"ALTER TABLE T0880" DISPLAY" DROP CONSTRAINT" DISPLAY"""It was the best of times; it was the worst of
- " times. THE END""" DISPLAY"CASCADE;" * EXEC SQL ALTER TABLE T0880 * DROP CONSTRAINT * "It was the best of times; it was the worst of times." * CASCADE; CALL"SUB12"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
* EXEC SQL COMMIT WORK; CALL"SUB20"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST0880 ******************** ******************** BEGIN TEST0881 ******************* MOVE 1 TO flag
DISPLAY" TEST0881" DISPLAY" Long character set names, domain names" DISPLAY"References:" DISPLAY" F#25 -- Domain definition" DISPLAY" F#39 -- Long identifiers" DISPLAY" F#45 -- Character set definition" DISPLAY" - - - - - - - - - - - - - - - - - - -"
COMPUTE SQLCODE = -1 MOVE"xxxxx"TO SQLSTATE
DISPLAY"CREATE CHARACTER SET" DISPLAY"""Little boxes on the hillside, Little boxes made
- " of ticky-tacky""" DISPLAY"GET SQL_TEXT;" * EXEC SQL CREATE CHARACTER SET * "Little boxes on the hillside, Little boxes made of * - " ticky-tacky" * GET SQL_TEXT; CALL"SUB21"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE DOMAIN" DISPLAY"""Little boxes on the hillside, Little boxes all
- " the same.""" DISPLAY"CHAR (4) CHARACTER SET" DISPLAY"""Little boxes on the hillside, Little boxes made
- " of ticky-tacky"";" * EXEC SQL CREATE DOMAIN * "Little boxes on the hillside, Little boxes all the * - " same." * CHAR (4) CHARACTER SET * "Little boxes on the hillside, Little boxes made of * - " ticky-tacky"; CALL"SUB23"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE TABLE T0881 ( C1" DISPLAY"""Little boxes on the hillside, Little boxes all
- " the same.""" DISPLAY");" * EXEC SQL CREATE TABLE T0881 ( C1 * "Little boxes on the hillside, Little boxes all the * - " same." * ); CALL"SUB25"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO T0881 VALUES ('ABCD');" * EXEC SQL INSERT INTO T0881 VALUES ('ABCD'); CALL"SUB27"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE 0 TO int1 DISPLAY"SELECT COUNT(*) INTO :int1 FROM T0881" DISPLAY" WHERE C1 = 'ABCD';" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM T0881 * WHERE C1 = 'ABCD'; CALL"SUB28"USING SQLCODE SQLSTATE int1 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 1; its value is ", int1 if (int1 NOT = 1) then MOVE 0 TO flag END-IF
DISPLAY"DROP DOMAIN" DISPLAY"""Little boxes on the hillside, Little boxes all
- " the same.""" DISPLAY"CASCADE;" * EXEC SQL DROP DOMAIN * "Little boxes on the hillside, Little boxes all the * - " same." * CASCADE; CALL"SUB32"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DROP CHARACTER SET" DISPLAY"""Little boxes on the hillside, Little boxes made
- " of ticky-tacky""" DISPLAY";" * EXEC SQL DROP CHARACTER SET * "Little boxes on the hillside, Little boxes made of * - " ticky-tacky" * ; CALL"SUB34"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
* EXEC SQL COMMIT WORK; CALL"SUB38"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST0881 ******************** **** 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.15 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.