* Standard COBOL (file "DML117.SCO") calling SQL * procedures in file "DML117.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1994/5/17 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. * * DML117.SCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * This routine tests FIPS feature 19. * This is the non-dynamic version of DML118.PC. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 * ****************************************************************
*The persistent audit records need to be consistent in the *event that a LUSER_ID is recycled after someone is deleted. *The original LUSER_ID is preserved in SAVED_LUSER_ID in case *it is needed.
DISPLAY"CREATE TABLE AUDIT_RECORDS (" DISPLAY" FOREIGN KEY (LUSER_ID) REFERENCES LUSERS ON
- " DELETE SET NULL," DISPLAY" LUSER_ID INT," DISPLAY" SAVED_LUSER_ID INT NOT NULL" DISPLAY" REFERENCES ALL_USER_IDS (LUSER_ID) ON DELETE
- " NO ACTION," DISPLAY" ACTION_KEY INT DEFAULT 0 NOT NULL" DISPLAY" REFERENCES AUDIT_CODES ON DELETE SET
- " DEFAULT);" * EXEC SQL CREATE TABLE AUDIT_RECORDS ( * FOREIGN KEY (LUSER_ID) REFERENCES LUSERS ON DELETE SET * NULL, * LUSER_ID INT, * SAVED_LUSER_ID INT NOT NULL * REFERENCES ALL_USER_IDS (LUSER_ID) ON DELETE NO ACTION, * ACTION_KEY INT DEFAULT 0 NOT NULL * REFERENCES AUDIT_CODES ON DELETE SET DEFAULT); CALL"SUB11"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO LUSER_DATA VALUES ('ROOT1'," DISPLAY" 0, 'BIFF is a total loser');" * EXEC SQL INSERT INTO LUSER_DATA VALUES ('ROOT1', * 0, 'BIFF is a total loser'); CALL"SUB22"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO LUSER_DATA VALUES ('ROOT2'," DISPLAY" 0, 'Kibo wastes disk space');" * EXEC SQL INSERT INTO LUSER_DATA VALUES ('ROOT2', * 0, 'Kibo wastes disk space'); CALL"SUB23"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*This angered root, who instantly disbursed group punishment...
DISPLAY"DELETE FROM LUSERS" DISPLAY" WHERE NAAM <> 'root';" * EXEC SQL DELETE FROM LUSERS WHERE NAAM <> 'root'; CALL"SUB32"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM LUSER_DATA;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM LUSER_DATA * ; CALL"SUB33"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 2; its value is ", int1 if (int1 NOT = 2) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM LUSERS;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM LUSERS; CALL"SUB34"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 1; its value is ", int1 if (int1 NOT = 1) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM AUDIT_RECORDS;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS * ; CALL"SUB35"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 12; its value is ", int1 if (int1 NOT = 12) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM AUDIT_RECORDS WHERE LUSER_ID IS NULL;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS * WHERE LUSER_ID IS NULL; CALL"SUB36"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 10; its value is ", int1 if (int1 NOT = 10) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM AUDIT_RECORDS WHERE SAVED_LUSER_ID IS
- " NULL;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS * WHERE SAVED_LUSER_ID IS NULL; CALL"SUB37"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 0; its value is ", int1 if (int1 NOT = 0) then MOVE 0 TO flag END-IF
*...and disabled deletes just for good measure.
DISPLAY"DELETE FROM AUDIT_CODES" DISPLAY" WHERE LUSER_ACTION = 'DELETE';" * EXEC SQL DELETE FROM AUDIT_CODES * WHERE LUSER_ACTION = 'DELETE'; CALL"SUB38"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS" DISPLAY" WHERE ACTION_KEY = 2;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS * WHERE ACTION_KEY = 2; CALL"SUB39"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 0; its value is ", int1 if (int1 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS" DISPLAY" WHERE ACTION_KEY = 0;" * EXEC SQL SELECT COUNT(*) INTO :int1 FROM AUDIT_RECORDS * WHERE ACTION_KEY = 0; CALL"SUB40"USINGSQLCODE SQLSTATE int1 MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 8; its value is ", int1 if (int1 NOT = 8) then MOVE 0 TO flag END-IF
*See if that "ON DELETE NO ACTION" did what it was supposed to d *It should _not_ allow us to create dangling references.
DISPLAY"DELETE FROM ALL_USER_IDS;" * EXEC SQL DELETE FROM ALL_USER_IDS; CALL"SUB41"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 23000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "23000") then MOVE 0 TO flag END-IF if (NORMSQ = "23000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
* EXEC SQL COMMIT WORK; CALL"SUB55"USINGSQLCODE SQLSTATE MOVESQLCODETO SQL-COD ******************** END TEST0645 ******************** **** 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.14 Sekunden
(vorverarbeitet am 2026-05-06)
¤
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.