* Standard COBOL (file "MPA012.SCO") calling SQL * procedures in file "MPA012.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1995/03/27 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. * * MPA012.SCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * This routine tests SET TRANSACTION ISOLATION LEVEL for * dynamic SQL. This is part A of a two-part program. * * References: * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 14.1 <set transaction statement> * ****************************************************************
******************** BEGIN TEST0590 ******************* MOVE1TO flag
*SQL-92 14.1 GR.5 says that a transaction at a particular *isolation level must not exhibit phenomena which are not *supposed to be possible at that level, but does not *require transactions to exhibit those phenomena which *are possible. A conforming implementation could simply *ignore all SET TRANSACTION ISOLATION LEVEL statements *and treat all transactions as SERIALIZABLE. The *phenomena are defined in SQL-92 4.28.
.
P163. if (debug1 NOT = 0) then DISPLAY"Debug trace: P163" END-IF * EXEC SQL INSERT INTO HU.TOKENS VALUES (:progno, 1); CALL"SUB15"USINGSQLCODE SQLSTATE progno MOVESQLCODETO SQL-COD if (SQLCODE < 0) then *Waste time and try again DISPLAY"SQLCODE = ", SQL-COD, " SQLSTATE = '",
SQLSTATE, "'" COMPUTE fails = fails + 1 if (fails > maxfls) then GOTO P199 END-IF *TEd hook for fixing delays: 012 * EXEC SQL ROLLBACK WORK; CALL"SUB16"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD MOVE1TO PLEN PERFORM SLEEEP THRU P133 * EXEC SQL ROLLBACK WORK; CALL"SUB17"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD GOTO P163 END-IF * EXEC SQL COMMIT WORK; CALL"SUB18"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD if (SQLCODE < 0) then *Waste time and try again DISPLAY"SQLCODE = ", SQL-COD, " SQLSTATE = '",
SQLSTATE, "'" COMPUTE fails = fails + 1 if (fails > maxfls) then GOTO P199 END-IF *TEd hook for fixing delays: 013 * EXEC SQL ROLLBACK WORK; CALL"SUB19"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD MOVE1TO PLEN PERFORM SLEEEP THRU P133 * EXEC SQL ROLLBACK WORK; CALL"SUB20"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD GOTO P163 END-IF
DISPLAY"START PROGRAM B if you haven't already!" MOVE2TO waitin
MOVE0TO fails COMPUTE oldtok = -1 DISPLAY"Waiting for the token to reach ", waitin, "."
.
P165. if (debug1 NOT = 0) then DISPLAY"Debug trace: P165" END-IF COMPUTE int1 = -1 * EXEC SQL SELECT TOKEN_NO INTO :int1 FROM HU.TOKENS * WHERE PROG_NO = :progno; CALL"SUB21"USINGSQLCODE SQLSTATE int1 progno MOVESQLCODETO SQL-COD if (SQLCODE < 0) then DISPLAY"SQLCODE = ", SQL-COD, " SQLSTATE = '",
SQLSTATE, "'" END-IF if (int1 NOT = oldtok ANDSQLCODENOT < 0AND SQLCODENOT = 100 ) then DISPLAY"Token = ", int1 MOVE int1 TO oldtok MOVE0TO fails END-IF if (SQLCODE < 0OR int1 NOT = waitin) then *Waste time and try again PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ = "21000") then GOTO P198 END-IF COMPUTE fails = fails + 1 if (fails > maxfls) then GOTO P199 END-IF *TEd hook for fixing delays: 014 * EXEC SQL ROLLBACK WORK; CALL"SUB22"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD MOVE2TO PLEN PERFORM SLEEEP THRU P133 * EXEC SQL ROLLBACK WORK; CALL"SUB23"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD GOTO P165 END-IF
*Check for dirty read
.
P137. if (debug1 NOT = 0) then DISPLAY"Debug trace: P137" END-IF DISPLAY"dstmt=""SET TRANSACTION ISOLATION LEVEL READ
- " COMMITTED""" MOVE"SET TRANSACTION ISOLATION LEVEL READ COMMITTED " TO dstmt
DISPLAY"PREPARE S1034 FROM :dstmt;" * EXEC SQL PREPARE S1034 FROM :dstmt; CALL"SUB24"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD if (SQLCODE < 0) then DISPLAY"Failure on PREPARE = failure on test" MOVE0TO flag END-IF DISPLAY"EXECUTE S1034;" * EXEC SQL EXECUTE S1034; CALL"SUB25"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD if (SQLCODE < 0) then DISPLAY"SQLCODE is ", SQL-COD DISPLAY"Failure on transaction statement = failure on
- " test" MOVE0TO flag END-IF *Give 'B' a chance to do its damage. DISPLAY"Begin SLEEEP (5)" *date_time print ACCEPT TO-DAY FROMDATE ACCEPT THE-TIME FROMTIME DISPLAY"Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME MOVE5TO PLEN PERFORM SLEEEP THRU P133 DISPLAY"End SLEEEP (5)" *date_time print ACCEPT TO-DAY FROMDATE ACCEPT THE-TIME FROMTIME DISPLAY"Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME *Check for dirty read. COMPUTE int1 = -1
DISPLAY"dstmt=""SELECT C1 FROM USG103 WHERE C_1 = 985""" MOVE"SELECT C1 FROM USG103 WHERE C_1 = 985 " TO dstmt
DISPLAY"PREPARE S1031 FROM :dstmt;" * EXEC SQL PREPARE S1031 FROM :dstmt; CALL"SUB26"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD
if (SQLCODE < 0) then DISPLAY"SQLCODE is ", SQL-COD DISPLAY"Failure on PREPARE = failure on test" MOVE0TO flag GOTO P150 END-IF DISPLAY"DECLARE C1031 CURSOR FOR S1031;" * EXEC SQL DECLARE C1031 CURSOR FOR S1031 END-EXEC
DISPLAY"OPEN C1031;" * EXEC SQL OPEN C1031; CALL"SUB27"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD if (SQLCODE < 0) then GOTO P138 END-IF
DISPLAY"FETCH C1031 INTO :int1;" * EXEC SQL FETCH C1031 INTO :int1; CALL"SUB28"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD if (SQLCODE < 0) then GOTO P138 END-IF DISPLAY"SQLCODE should be 100; its value is ", SQL-COD if (SQLCODENOT = 100) then MOVE0TO flag END-IF
DISPLAY"CLOSE C1031;" * EXEC SQL CLOSE C1031; CALL"SUB29"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD if (SQLCODE < 0) then GOTO P138 END-IF
.
P177. if (debug1 NOT = 0) then DISPLAY"Debug trace: P177" END-IF DISPLAY"SQLCODE is ", SQL-COD COMPUTE fails = fails + 1 if (fails > maxfls) then GOTO P199 END-IF * EXEC SQL ROLLBACK WORK; CALL"SUB69"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD GOTO P173
.
P179. *Make sure syntax of READ UNCOMMITTED is accepted. There's noth *else to test since its semantics allow ANYTHING. if (debug1 NOT = 0) then DISPLAY"Debug trace: P179" END-IF DISPLAY"The following syntax should be accepted." DISPLAY"dstmt=""SET TRANSACTION ISOLATION LEVEL READ
- " UNCOMMITTED""" MOVE"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED " TO dstmt DISPLAY"EXECUTE IMMEDIATE :dstmt;" * EXEC SQL EXECUTE IMMEDIATE :dstmt; CALL"SUB70"USINGSQLCODE SQLSTATE dstmt MOVESQLCODETO SQL-COD if (SQLCODE < 0) then DISPLAY"SQLCODE is ", SQL-COD DISPLAY"Failure on transaction statement = failure on
- " test" MOVE0TO flag END-IF
.
P150. if (debug1 NOT = 0) then DISPLAY"Debug trace: P150" END-IF DISPLAY"ROLLBACK WORK;" * EXEC SQL ROLLBACK WORK; CALL"SUB71"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD
******************** END TEST0590 ******************** STOPRUN.
P198. if (debug1 NOT = 0) then DISPLAY"Debug trace: P198" END-IF DISPLAY"CARDINALITY VIOLATION"
.
P199. * EXEC SQL ROLLBACK WORK; CALL"SUB77"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD if (debug1 NOT = 0) then DISPLAY"Debug trace: P199" END-IF if (fails > maxfls) then DISPLAY"The number of attempts (fails) exceeds variable
- " maxfls." DISPLAY"Increase the value of variable maxfls, if
- " needed." DISPLAY"Or, increase the value of variable pauze." END-IF DISPLAY"MAYDAY MAYDAY PROGRAM ABORTING" DISPLAY"You will have to start this test over." DISPLAY"Trying to kill token (no retries)...." * EXEC SQL DELETE FROM HU.TOKENS WHERE PROG_NO = :progno * ; CALL"SUB78"USINGSQLCODE SQLSTATE progno MOVESQLCODETO SQL-COD * EXEC SQL COMMIT WORK; CALL"SUB79"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD STOPRUN.
* **** Procedures for PERFORM statements
*TEd hook to replace SLEEEP routine #1
SLEEEP. COMPUTE repcnt = pauze * plen MOVE1TO iii
.
P133. COMPUTE int3 = -1 * EXEC SQL UPDATE HU.STAFF3 * SET EMPNAME = NULL WHERE GRADE = :int3; CALL"SUB80"USINGSQLCODE SQLSTATE int3 MOVESQLCODETO SQL-COD COMPUTE iii = iii + 1 if (iii < repcnt) then GOTO P133 END-IF *TEd hook to replace SLEEEP routine #2
.
*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 = 0OR NORMSQ NOT = "00000") then MOVE0TO 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
MOVE3TO norm1 *subclass begins in position 3 of char array NORMSQ *valid subclass begins with 5-9, I-Z, end of ALPNUM table PERFORMVARYING norm2 FROM14BY1UNTIL 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
MOVE4TO norm1 *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORMVARYING norm2 FROM1BY1UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
MOVE5TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING norm2 FROM1BY1UNTIL 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.25 Sekunden
(vorverarbeitet am 2026-09-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.
Forschung weltweit
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.