* Standard COBOL (file "XTS766.SCO") calling SQL * procedures in file "XTS766.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 * * XTS766.SCO * WRITTEN BY: Nickos Backalidis * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * Drop character set no granted privileges * * REFERENCES * 11.29 -- <Drop character set statement> * TC#1 11.29 * 11.29 AR.1 * 11.29 SR.3 * 21.2.12 -- USAGE_PRIVILEGES view * 21.3.22 -- USAGE_PRIVILEGES base table * F#23 -- Privilege Tables * F#2 -- Basic Information Schema * F#45 -- Character set definition. * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 18/12/95 * Print timestamp * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * * QA STATUS : QA CHECK * * Revised by DWF 1996-02-23 * Shortened variable names to 6 chars * Removed field widths from printfs * Fixed SDL transactions * Corrected printout * Fixed SQL syntax errors * Fixed bad schema references ****************************************************************
*create a character set under the current schema DISPLAY"CREATE CHARACTER SET TESTSET GET SQL_TEXT;" * EXEC SQL CREATE CHARACTER SET TESTSET GET SQL_TEXT; CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*access the USAGE_PRIVILEGES view from the Information *and ensure that the character set is visible DISPLAY"SELECT GRANTOR, GRANTEE, OBJECT_SCHEMA,
- " OBJECT_NAME, OBJECT_TYPE" DISPLAY"INTO :gtor, :gtee ,:objsch, :objnam, :objtyp " DISPLAY"FROM INFORMATION_SCHEMA.USAGE_PRIVILEGES " DISPLAY"WHERE OBJECT_TYPE = 'CHARACTER SET'" DISPLAY"AND OBJECT_NAME = 'TESTSET';"
*intialise host variables MOVE"xxxxxxxxxxxxxxxxxxxx"TO gtor MOVE"xxxxxxxxxxxxxxxxxxxx"TO gtee MOVE"xxxxxxxxxxxxxxxxxxxx"TO objsch MOVE"xxxxxxxxxxxxxxxxxxxx"TO objnam MOVE"xxxxxxxxxxxxxxxxxxxx"TO objtyp * EXEC SQL SELECT GRANTOR, GRANTEE, OBJECT_SCHEMA, * OBJECT_NAME, OBJECT_TYPE * INTO :gtor, :gtee ,:objsch, :objnam, :objtyp * FROM INFORMATION_SCHEMA.USAGE_PRIVILEGES * WHERE OBJECT_TYPE = 'CHARACTER SET' * AND OBJECT_NAME = 'TESTSET'; CALL"SUB5"USING SQLCODE SQLSTATE gtor gtee objsch objnam
objtyp MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"GRANTOR should be _SYSTEM; its value
- " is ", gtor DISPLAY"GRANTEE should be CTS1; its value
- " is ", gtee DISPLAY"OBJECT_SCHEMA should be CTS1; its value
- " is ", objsch DISPLAY"OBJECT_TYPE should be CHARACTER SET; its value
- " is ", objtyp DISPLAY"OBJECT_NAME should be TESTSET; its value
- " is ", objnam if (gtor NOT = "_SYSTEM"OR gtee NOT = "CTS1") then MOVE 0 TO flag END-IF if (objsch NOT = "CTS1"OR objtyp NOT = "CHARACTER SET") then MOVE 0 TO flag END-IF if (objnam NOT = "TESTSET") then MOVE 0 TO flag END-IF DISPLAY" "
*11.29 drop character set does NOT get a drop behavior! *It's always restrict (see SR.3 in TC)
DISPLAY"DROP CHARACTER SET TESTSET;" * EXEC SQL DROP CHARACTER SET TESTSET; CALL"SUB7"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE 1 TO coun *now access the character sets view and check that *no data will be returned for CTS1 & TESTSET DISPLAY"SELECT COUNT(*) INTO :coun" DISPLAY" FROM INFORMATION_SCHEMA.CHARACTER_SETS " DISPLAY" WHERE CHARACTER_SET_SCHEMA = 'CTS1'" DISPLAY" AND CHARACTER_SET_NAME = 'TESTSET';" * EXEC SQL SELECT COUNT(*) INTO :coun * FROM INFORMATION_SCHEMA.CHARACTER_SETS * WHERE CHARACTER_SET_SCHEMA = 'CTS1' * AND CHARACTER_SET_NAME = 'TESTSET'; CALL"SUB9"USING SQLCODE SQLSTATE coun MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"coun should be 0; its value is ", coun if (coun NOT = 0) then MOVE 0 TO flag END-IF
if ( flag = 1 ) then DISPLAY" xts766.mco *** pass *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7066','pass','MCO'); CALL"SUB11"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD else DISPLAY" xts766.mco *** fail *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7066','fail','MCO'); CALL"SUB12"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
DISPLAY"========================================"
* EXEC SQL COMMIT WORK; CALL"SUB13"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST7066 ********************
**** 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.47 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.