* Standard COBOL (file "MPB012.SCO") calling SQL * procedures in file "MPB012.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1995/03/28 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. * * MPB012.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 B of a two-part program. * * References: * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 14.1 <set transaction statement> * ****************************************************************
MOVE"SULLIVAN1 "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx * EXEC SQL SELECT USER INTO :uidx FROM HU.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, mpb012.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
DISPLAY"This is part B of a two-part test. It should be
- " started" DISPLAY"AFTER mpa012. Table TOKENS must exist in schema
- " HU."
*to debug program, set debug1 = 1 MOVE 0 TO debug1 MOVE 100 TO maxfls MOVE 100 TO pauze MOVE 12 TO progno
******************** BEGIN TEST0590 ******************* MOVE 1 TO 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.
******************** END TEST0590 ******************** STOPRUN.
P198. if (debug1 NOT = 0) then DISPLAY"Debug trace: P198" END-IF DISPLAY"CARDINALITY VIOLATION"
.
P199. * EXEC SQL ROLLBACK WORK; CALL"SUB45"USING SQLCODE SQLSTATE MOVE SQLCODE TO 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"SUB46"USING SQLCODE SQLSTATE progno MOVE SQLCODE TO SQL-COD * EXEC SQL COMMIT WORK; CALL"SUB47"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD STOPRUN.
* **** Procedures for PERFORM statements
*TEd hook to replace SLEEEP routine #1
SLEEEP. COMPUTE repcnt = pauze * plen MOVE 1 TO iii
.
P333. COMPUTE int3 = -1 * EXEC SQL UPDATE HU.STAFF * SET GRADE = -1 WHERE GRADE = :int3; CALL"SUB48"USING SQLCODE SQLSTATE int3 MOVE SQLCODE TO SQL-COD COMPUTE iii = iii + 1 if (iii < repcnt) then GOTO P333 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 (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.24 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.