* Standard COBOL (file "XTS749.SCO") calling SQL * procedures in file "XTS749.MCO".
*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 * * XTS749.SCO * WRITTEN BY: Manolis Megaloikonomou * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * Named table constraint in table definition. * * REFERENCES * 11.3 -- <table definition> * 11.6 -- <table constraint definition>. * 11.6 SR.1 * 11.6 GR.2 * 11.6 LR.2a -- Raised. Entry SQL restriction which * prohibits the use of a * <constraint name definition>. * 10.6 -- <constraint name definition> and * <constraint attributes> * 10.6 SR.1 * 10.6 SR.2 * 10.6 LR.2a -- Raised. Entry SQL restriction which * prohibits the use of a * <constraint name definition>. * 11.7 -- <unique constraint definition> * 11.8 -- <referential constraint definition> * 11.9 -- <check constraint definition> * F#2 -- Basic information schema. * F#3 -- Basic schema manipulation. * F#33 -- Constraint tables. * F#49 -- Constraint management. * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 08/12/95 * Print timestamp * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * Include string initialisation * Clean-up database at the end of test * * QA Status: Full FC * * Revised by DWF 1996-02-15 * Cleanups * Removed status checks after cursor definitions * Fixed transactions * Removed field widths from printfs ****************************************************************
MOVE 999 TO coun DISPLAY"SELECT COUNT(*) INTO :coun" DISPLAY"FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS" DISPLAY"WHERE CONSTRAINT_SCHEMA = 'CTS1' AND TABLE_SCHEMA
- " = 'CTS1'" DISPLAY"AND TABLE_NAME = 'TEST12649';" * EXEC SQL SELECT COUNT(*) INTO :coun * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS * WHERE CONSTRAINT_SCHEMA = 'CTS1' AND TABLE_SCHEMA = * 'CTS1' * AND TABLE_NAME = 'TEST12649'; CALL"SUB5"USING SQLCODE SQLSTATE coun MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"Count should be 3; its value is ", coun if ( coun NOT = 3 ) then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"DECLARE a CURSOR FOR SELECT CONSTRAINT_NAME,
- " CONSTRAINT_TYPE" DISPLAY"FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS" DISPLAY"WHERE CONSTRAINT_SCHEMA = 'CTS1' AND TABLE_SCHEMA
- " = 'CTS1'" DISPLAY"AND TABLE_NAME = 'TEST12649'" DISPLAY"ORDER BY CONSTRAINT_NAME;" * EXEC SQL DECLARE a CURSOR FOR SELECT CONSTRAINT_NAME, * CONSTRAINT_TYPE * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS * WHERE CONSTRAINT_SCHEMA = 'CTS1' AND TABLE_SCHEMA = * 'CTS1' * ORDER BY CONSTRAINT_NAME END-EXEC
DISPLAY"OPEN a;" * EXEC SQL OPEN a; CALL"SUB6"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"FETCH a INTO :cname, :ctype;" * EXEC SQL FETCH a INTO :cname, :ctype; CALL"SUB7"USING SQLCODE SQLSTATE cname ctype MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"cname should be CND12549A; its value is ", cname DISPLAY"ctype should be PRIMARY KEY; its value is ", ctype if (cname NOT = "CND12549A"OR ctype NOT = "PRIMARY KEY") then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"FETCH a INTO :cname, :ctype;" * EXEC SQL FETCH a INTO :cname, :ctype; CALL"SUB8"USING SQLCODE SQLSTATE cname ctype MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"cname should be CND12549B; its value is ", cname DISPLAY"ctype should be CHECK; its value is ", ctype if (cname NOT = "CND12549B"OR ctype NOT = "CHECK") then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"FETCH a INTO :cname, :ctype;" * EXEC SQL FETCH a INTO :cname, :ctype; CALL"SUB9"USING SQLCODE SQLSTATE cname ctype MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"cname should be CND12549C; its value is ", cname DISPLAY"ctype should be FOREIGN KEY; its value is ", ctype if (cname NOT = "CND12549C"OR ctype NOT = "FOREIGN KEY") then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"CLOSE a;" * EXEC SQL CLOSE a; CALL"SUB10"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
******************** END TEST7049 ********************
**** 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.
¤ Dauer der Verarbeitung: 0.12 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.