* Standard COBOL (file "DML126.SCO") calling SQL * procedures in file "DML126.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1994/7/1 STANDARD COBOL LANGUAGE * NIST 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. * * DML126.SCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * This routine tests Dynamic SQL SQLSTATEs and F# 12. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 * ****************************************************************
*This one cannot be generated in TSQL because first you have to *violate the syntactical leveling rule against specifying INTO *with an EXECUTE.
*07005 prepared statement not a cursor specification *Before correction: 17.6 GR.9.b.ii *After correction: 17.6 GR.9.b.i
*4.22 <dynamic declare cursor> is declarative - not executable DISPLAY"DECLARE C12611 CURSOR FOR S12611;" * EXEC SQL DECLARE C12611 CURSOR FOR S12611 END-EXEC DISPLAY" "
DISPLAY"dstmt=""INSERT INTO CONCATBUF VALUES (?)""" MOVE"INSERT INTO CONCATBUF VALUES (?) " TO dstmt
*07005 cannot be pushed back to the open (see above citation)
DISPLAY"PREPARE S12611 FROM :dstmt;" * EXEC SQL PREPARE S12611 FROM :dstmt; CALL"SUB3"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07005; its value is ", SQLSTATE if (SQLSTATE NOT = "07005"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
DISPLAY"OPEN C12611;" * EXEC SQL OPEN C12611; CALL"SUB4"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD if (SQLCODENOT < 0) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 26000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "26000") then MOVE 0 TO flag END-IF if (NORMSQ = "26000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"PREPARE S12613 FROM :dstmt;" * EXEC SQL PREPARE S12613 FROM :dstmt; CALL"SUB6"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*07006 restricted data type attribute violation *See test 0658
*07001 using clause does not match dynamic parameter specificati *17.9 GR.5.a
MOVE"xxxxxxxxxx"TO ch1 MOVE"xxxxxxxxxx"TO ch2
DISPLAY"EXECUTE S12613 USING :ch1, :ch2;" * EXEC SQL EXECUTE S12613 USING :ch1, :ch2; CALL"SUB7"USINGSQLCODE SQLSTATE ch1 ch2 MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07001; its value is ", SQLSTATE if (SQLSTATE NOT = "07001"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
*07002 using clause does not match target specifications *17.9 GR.6.a
DISPLAY"dstmt=""SELECT * FROM HU.WORKS WHERE HOURS = ?""" MOVE"SELECT * FROM HU.WORKS WHERE HOURS = ?
- " "TO dstmt
DISPLAY"PREPARE S12612 FROM :dstmt;" * EXEC SQL PREPARE S12612 FROM :dstmt; CALL"SUB8"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C12612 CURSOR FOR S12612;" * EXEC SQL DECLARE C12612 CURSOR FOR S12612 END-EXEC DISPLAY" "
MOVE 12 TO int1 DISPLAY"OPEN C12612 USING :int1;" * EXEC SQL OPEN C12612 USING :int1; CALL"SUB9"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"FETCH C12612 INTO :ch1;" * EXEC SQL FETCH C12612 INTO :ch1; CALL"SUB10"USINGSQLCODE SQLSTATE ch1 MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07002; its value is ", SQLSTATE if (SQLSTATE NOT = "07002"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
*07001 using clause does not match dynamic parameter specificati *17.9 GR.5.a
MOVE 12 TO int1 MOVE"xxxxxxxxxx"TO ch1 DISPLAY"OPEN C12612 USING :int1, :ch1;" * EXEC SQL OPEN C12612 USING :int1, :ch1; CALL"SUB12"USINGSQLCODE SQLSTATE int1 ch1 MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07001; its value is ", SQLSTATE if (SQLSTATE NOT = "07001"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
*07004 using clause required for dynamic parameters *17.14 GR.3
DISPLAY"OPEN C12612;" * EXEC SQL OPEN C12612; CALL"SUB14"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07004; its value is ", SQLSTATE if (SQLSTATE NOT = "07004"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
*07004 using clause required for dynamic parameters *17.10 GR.4
DISPLAY"EXECUTE S12613;" * EXEC SQL EXECUTE S12613; CALL"SUB16"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 07004; its value is ", SQLSTATE if (SQLSTATE NOT = "07004"ORSQLCODENOT < 0) then MOVE 0 TO flag END-IF
*07007 using clause required for result fields
*This one cannot be generated in TSQL because first you have to *violate the syntactical leveling rule against specifying INTO *with an EXECUTE.
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB22"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'ALLOCATE DESCRIPTOR '; its value
- " is ", cmd if (cmd NOT = "ALLOCATE DESCRIPTOR ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB24"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'SET DESCRIPTOR '; its value
- " is ", cmd if (cmd NOT = "SET DESCRIPTOR ") then MOVE 0 TO flag END-IF
*PREPARE
DISPLAY"dstmt=""SELECT HOURS FROM HU.WORKS""" MOVE"SELECT HOURS FROM HU.WORKS " TO dstmt
DISPLAY"PREPARE S12621 FROM :dstmt;" * EXEC SQL PREPARE S12621 FROM :dstmt; CALL"SUB25"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB26"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'PREPARE '; its value
- " is ", cmd if (cmd NOT = "PREPARE ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB28"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DESCRIBE '; its value
- " is ", cmd if (cmd NOT = "DESCRIBE ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB30"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'GET DESCRIPTOR '; its value
- " is ", cmd if (cmd NOT = "GET DESCRIPTOR ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB32"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DEALLOCATE DESCRIPTOR'; its value
- " is ", cmd if (cmd NOT = "DEALLOCATE DESCRIPTOR") then MOVE 0 TO flag END-IF
*DYNAMIC OPEN
DISPLAY"DECLARE C12621 CURSOR FOR S12621;" * EXEC SQL DECLARE C12621 CURSOR FOR S12621 END-EXEC
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB34"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DYNAMIC OPEN '; its value
- " is ", cmd if (cmd NOT = "DYNAMIC OPEN ") then MOVE 0 TO flag END-IF
*DYNAMIC FETCH
DISPLAY"FETCH C12621 INTO :int1;" * EXEC SQL FETCH C12621 INTO :int1; CALL"SUB35"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB36"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DYNAMIC FETCH '; its value
- " is ", cmd if (cmd NOT = "DYNAMIC FETCH ") then MOVE 0 TO flag END-IF
*DYNAMIC UPDATE CURSOR
DISPLAY"UPDATE HU.WORKS SET HOURS = 10" DISPLAY" WHERE CURRENT OF C12621;" * EXEC SQL UPDATE HU.WORKS SET HOURS = 10 * WHERE CURRENT OF C12621; CALL"SUB37"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB38"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DYNAMIC UPDATE CURSOR'; its value
- " is ", cmd if (cmd NOT = "DYNAMIC UPDATE CURSOR") then MOVE 0 TO flag END-IF
DISPLAY"DELETE FROM HU.WORKS WHERE CURRENT OF C12621;" * EXEC SQL DELETE FROM HU.WORKS WHERE CURRENT OF C12621 * ; CALL"SUB39"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB40"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DYNAMIC DELETE CURSOR'; its value
- " is ", cmd if (cmd NOT = "DYNAMIC DELETE CURSOR") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB42"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DYNAMIC CLOSE '; its value
- " is ", cmd if (cmd NOT = "DYNAMIC CLOSE ") then MOVE 0 TO flag END-IF
*EXECUTE
DISPLAY"dstmt=""INSERT INTO CONCATBUF VALUES ('SPAM')""" MOVE"INSERT INTO CONCATBUF VALUES ('SPAM') " TO dstmt
DISPLAY"PREPARE S12622 FROM :dstmt;" * EXEC SQL PREPARE S12622 FROM :dstmt; CALL"SUB43"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB45"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'EXECUTE '; its value
- " is ", cmd if (cmd NOT = "EXECUTE ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = COMMAND_FUNCTION; CALL"SUB47"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'EXECUTE IMMEDIATE '; its value
- " is ", cmd if (cmd NOT = "EXECUTE IMMEDIATE ") then MOVE 0 TO flag END-IF
DISPLAY"INSERT INTO CONCATBUF VALUES ('AAA');" * EXEC SQL INSERT INTO CONCATBUF VALUES ('AAA'); CALL"SUB52"USINGSQLCODE SQLSTATE DISPLAY" "
*SELECT
DISPLAY"dstmt=""SELECT COUNT(*) FROM USIG""" MOVE"SELECT COUNT(*) FROM USIG
- " "TO dstmt
DISPLAY"PREPARE S12631 FROM :dstmt;" * EXEC SQL PREPARE S12631 FROM :dstmt; CALL"SUB53"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB54"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'SELECT '; its value
- " is ", cmd if (cmd NOT = "SELECT ") then MOVE 0 TO flag END-IF
*Intentional repetition -- GET DIAGNOSTICS should not set diagno
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB55"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'SELECT '; its value
- " is ", cmd if (cmd NOT = "SELECT ") then MOVE 0 TO flag END-IF
*DELETE WHERE
DISPLAY"dstmt=""DELETE FROM CONCATBUF""" MOVE"DELETE FROM CONCATBUF " TO dstmt
DISPLAY"PREPARE S12632 FROM :dstmt;" * EXEC SQL PREPARE S12632 FROM :dstmt; CALL"SUB56"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB57"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DELETE WHERE '; its value
- " is ", cmd if (cmd NOT = "DELETE WHERE ") then MOVE 0 TO flag END-IF
*INSERT
DISPLAY"dstmt=""INSERT INTO CONCATBUF VALUES (?)""" MOVE"INSERT INTO CONCATBUF VALUES (?) " TO dstmt
DISPLAY"PREPARE S12633 FROM :dstmt;" * EXEC SQL PREPARE S12633 FROM :dstmt; CALL"SUB58"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB59"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'INSERT '; its value
- " is ", cmd if (cmd NOT = "INSERT ") then MOVE 0 TO flag END-IF
*UPDATE WHERE
DISPLAY"dstmt=""UPDATE CONCATBUF SET ZZ = ?""" MOVE"UPDATE CONCATBUF SET ZZ = ? " TO dstmt
DISPLAY"PREPARE S12634 FROM :dstmt;" * EXEC SQL PREPARE S12634 FROM :dstmt; CALL"SUB60"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB61"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'UPDATE WHERE '; its value
- " is ", cmd if (cmd NOT = "UPDATE WHERE ") then MOVE 0 TO flag END-IF
*Unrecognized statement: TC #2 18.1 *If your database recognizes FROB, change it to a command *that it doesn't recognize. This should not be rejected at *compile time because it's Dynamic SQL.
DISPLAY"dstmt=""FROB""" MOVE"FROB " TO dstmt
DISPLAY"PREPARE S12635 FROM :dstmt;" * EXEC SQL PREPARE S12635 FROM :dstmt; CALL"SUB62"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd2 DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION," DISPLAY" :cmd2 = COMMAND_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION, * :cmd2 = COMMAND_FUNCTION; CALL"SUB63"USINGSQLCODE SQLSTATE cmd cmd2 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be ' '; its value
- " is '", cmd, "'" if (cmd NOT = " ") then MOVE 0 TO flag END-IF DISPLAY"cmd2 should be 'PREPARE '; its value
- " is '", cmd2, "'" if (cmd2 NOT = "PREPARE ") then MOVE 0 TO flag END-IF
*Execute UPDATE WHERE
MOVE"If an SQL-transaction"TO cmd DISPLAY"cmd = ", cmd
DISPLAY"EXECUTE S12634 USING :cmd;" * EXEC SQL EXECUTE S12634 USING :cmd; CALL"SUB64"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB65"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'UPDATE WHERE '; its value
- " is ", cmd if (cmd NOT = "UPDATE WHERE ") then MOVE 0 TO flag END-IF
*Frob even faster *If your database recognizes FROB, change it to a command *that it doesn't recognize. This should not be rejected at *compile time because it's Dynamic SQL.
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB67"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be ' '; its value
- " is '", cmd "'" if (cmd NOT = " ") then MOVE 0 TO flag END-IF
*Execute immediate INSERT
DISPLAY"dstmt=""INSERT INTO CONCATBUF VALUES ('FNORD')""" MOVE"INSERT INTO CONCATBUF VALUES ('FNORD') " TO dstmt
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB69"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'INSERT '; its value
- " is ", cmd if (cmd NOT = "INSERT ") then MOVE 0 TO flag END-IF
MOVE"xxxxxxxxxxxxxxxxxxxxx"TO cmd DISPLAY"GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION;" * EXEC SQL GET DIAGNOSTICS :cmd = DYNAMIC_FUNCTION; CALL"SUB71"USINGSQLCODE SQLSTATE cmd MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"cmd should be 'DELETE WHERE '; its value
- " is ", cmd if (cmd NOT = "DELETE WHERE ") then MOVE 0 TO flag END-IF
* EXEC SQL COMMIT WORK; CALL"SUB75"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD ******************** END TEST0671 ******************** **** 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 (SQLCODENOT = 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.
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-04-27)
¤
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 und die Messung sind noch experimentell.