*Copyright 1995 National Computing Centre Limited *and Computer Logic R&D S.A *on behalf of the CTS5 SQL2 Project. *All rights reserved. *The CTS5 SQL2 Project is sponsored by the European Community. * *The National Computing Centre Limited and Computer Logic R&D *have given permission to NIST to distribute this program *over the World Wide Web in order to promote SQL standards. *DISCLAIMER: *This program was reviewed by employees of NIST for *conformance to the SQL standards. *NIST assumes no responsibility for any party's use of *this program.
**************************************************************** * * COMMENT SECTION * * SQL VALIDATION TEST SUITE V6.0 * * XTS751.PCO * WRITTEN BY: Manolis Megaloikonomou * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * This routine tests Name of violated column constraint * returned in diagnostics. * * * REFERENCES * 18.1 -- <Get diagnostics statement> * 18.1 LR.2a -- Raised. Entry SQL restriction which * prohibited the use of * a <get diagnostics statement>. * 11.4 -- <column definition> * 11.6 -- <table constraint definition> * 11.7 -- <unique constraint definition> * 11.8 -- <referential constraint definition> * 11.9 -- <check constraint definition> * F#12 -- Get diagnostics. * F#30 -- Table operations. * F#49 -- Constraint management. * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 15/12/95 * Print timestamp * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * * QA STATUS : * * Revised by DWF 1996-02-15 * Entire test horribly broken; major changes to everything. ****************************************************************
MOVE"CTS1 "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECT USER INTO :uidx FROM CTS1.ECCO END-EXEC MOVE SQLCODE TO SQL-COD EXECSQL ROLLBACK WORK END-EXEC 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, Embedded COBOL, xts751.pco" 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
******************** BEGIN TEST7051 *******************
MOVE 1 TO flag DISPLAY" TEST7051 " DISPLAY" Name of violated column constraint returned in
- " diagnostics." DISPLAY"References:" DISPLAY" 18.1 -- " DISPLAY" 18.1 LR.2a -- Raised. Entry SQL restriction
- " which" DISPLAY" prohibited the use of" DISPLAY" a ." DISPLAY" 11.4 -- " DISPLAY" 11.6 --
DISPLAY"INSERT INTO CTS1.TEST12849A
- " VALUES(3,'JACK','TOKYO',3,'WHITE',3,2);" EXECSQLINSERTINTO CTS1.TEST12849A
VALUES(3,'JACK','TOKYO',3,'WHITE',3,2) END-EXEC MOVE SQLCODE TO SQL-COD DISPLAY" "
DISPLAY"GET DIAGNOSTICS" DISPLAY"EXCEPTION 1" DISPLAY":rstate = RETURNED_SQLSTATE," DISPLAY":cntnam = CONSTRAINT_NAME;" EXECSQL GET DIAGNOSTICS EXCEPTION 1
:rstate = RETURNED_SQLSTATE,
:cntnam = CONSTRAINT_NAME END-EXEC MOVE SQLCODE TO SQL-COD MOVE rstate TO SQLSTATE DISPLAY"RETURNED_SQLSTATE should be 23000; its value is ",
rstate DISPLAY"CONSTRAINT_NAME should be CONSTR_2; its value is
- " ", cntnam 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 if (cntnam NOT = "CONSTR_2") then MOVE 0 TO flag END-IF DISPLAY" "
*Insert one more row in the table attempting to violate *the foreign key constraint by inserting a non existing *value for the referenced column.
DISPLAY"INSERT INTO CTS1.TEST12849A
- " VALUES(4,'KEVIN','DUBLIN',9,'RED',9,4);" EXECSQLINSERTINTO CTS1.TEST12849A
VALUES(4,'KEVIN','DUBLIN',9,'RED',9,4) END-EXEC MOVE SQLCODE TO SQL-COD DISPLAY" "
DISPLAY"GET DIAGNOSTICS" DISPLAY"EXCEPTION 1" DISPLAY":rstate = RETURNED_SQLSTATE," DISPLAY":cntnam = CONSTRAINT_NAME;" EXECSQL GET DIAGNOSTICS EXCEPTION 1
:rstate = RETURNED_SQLSTATE,
:cntnam = CONSTRAINT_NAME END-EXEC MOVE SQLCODE TO SQL-COD MOVE rstate TO SQLSTATE DISPLAY"RETURNED_SQLSTATE should be 23000; its value is ",
rstate DISPLAY"CONSTRAINT_NAME should be CONSTR_1; its value is
- " ", cntnam 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 if (cntnam NOT = "CONSTR_1") then MOVE 0 TO flag END-IF DISPLAY" "
*Insert one more row in the table attempting to insert in *the column associated with the other referential constraint
DISPLAY"INSERT INTO CTS1.TEST12849A
- " VALUES(5,'FOO','LONDON',5,'GREEN',2,5);" EXECSQLINSERTINTO CTS1.TEST12849A
VALUES(5,'FOO','LONDON',5,'GREEN',2,5) END-EXEC MOVE SQLCODE TO SQL-COD DISPLAY" "
DISPLAY"GET DIAGNOSTICS" DISPLAY"EXCEPTION 1" DISPLAY":rstate = RETURNED_SQLSTATE," DISPLAY":cntnam = CONSTRAINT_NAME;" EXECSQL GET DIAGNOSTICS EXCEPTION 1
:rstate = RETURNED_SQLSTATE,
:cntnam = CONSTRAINT_NAME END-EXEC MOVE SQLCODE TO SQL-COD MOVE rstate TO SQLSTATE DISPLAY"RETURNED_SQLSTATE should be 23000; its value is ",
rstate DISPLAY"CONSTRAINT_NAME should be CONSTR_3; its value is
- " ", cntnam 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 if (cntnam NOT = "CONSTR_3") then MOVE 0 TO flag END-IF DISPLAY" "
*undo the insertion of the rows DISPLAY"ROLLBACK WORK;" EXECSQL ROLLBACK WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
if ( flag = 1 ) then DISPLAY" xts751.pco *** pass *** " EXECSQLINSERTINTO CTS1.TESTREPORT
VALUES('7051','pass','PCO') END-EXEC MOVE SQLCODE TO SQL-COD else DISPLAY" xts751.pco *** fail *** " EXECSQLINSERTINTO CTS1.TESTREPORT
VALUES('7051','fail','PCO') END-EXEC MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
DISPLAY"========================================"
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST7051 ********************
**** 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.
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.2Angebot
Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können
¤
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.