* Standard COBOL (file "XTS736.SCO") calling SQL * procedures in file "XTS736.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 * * XTS736.SCO * WRITTEN BY: Nickos Backalidis * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * Update NCHAR VARYING column with value from NCHAR domain * * REFERENCES * 11.21 -- <Domain definition> * 11.5 -- <default clause> * 6.1 -- <data type> * 6.1 SR.2 * 6.1 SR.9b * 5.3 -- <Literal> * 11.3 -- <Table definition> * 11.4 -- <column definition> * 13.10 -- <update statement: searched> * F#3 -- Basic schema manipulation * F#6 -- VARCHAR data type * F#25 -- Domain definition * F#22 -- Explicit defaults * F#42 -- National Character * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 07/12/95 * Include Files * Define NOSUBCLASS/CHCKOK at test beginning * print timestamp * * QA STATUS : QA CHECK 2 * * Revised by DWF 1996-02-08 * Fixed SDL transactions * Removed status checks after cursor definition * Fixed nchar literals * Fixed C variable declarations * Corrected expected result * Fixed SQL syntax error ****************************************************************
DISPLAY" " DISPLAY"When the character set name of NATIONAL CHARACTER
- " is known" DISPLAY"please use TED hooks to replace VANGELIS with the
- " " DISPLAY"implementation dependent national
- " name>" DISPLAY"and the values used in nat. char. literals with
- " permissible" DISPLAY"values from that specific character set
- " repertoire." DISPLAY" "
*create three domains under the current schema DISPLAY"CREATE DOMAIN DOM1 AS NATIONAL CHARACTER
- " VARYING(10)" DISPLAY"DEFAULT _VANGELIS 'KILLER'" * EXEC SQL CREATE DOMAIN DOM1 AS NATIONAL CHARACTER * VARYING(10) * DEFAULT _VANGELIS 'KILLER'; CALL"SUB3"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*now update the row where COLK = 2 using an <update *statement :searched> DISPLAY"UPDATE TAB736 " DISPLAY"SET COL1 = DEFAULT," DISPLAY"COL2 = DEFAULT," DISPLAY"COL3 = N'NEW YORK'" DISPLAY"WHERE COLK = 2;" * EXEC SQL UPDATE TAB736 * SET COL1 = DEFAULT, * COL2 = DEFAULT, * COL3 = N'NEW YORK' * WHERE COLK = 2; CALL"SUB14"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*use an ordered cursor and retrieve the rows of TAB736 *and check if the update was successful *and that the rows are returned DISPLAY"DECLARE V CURSOR FOR SELECT COLK,COL1,COL2,COL3" DISPLAY"FROM TAB736 " DISPLAY"ORDER BY COLK DESC;" * EXEC SQL DECLARE V CURSOR FOR SELECT COLK,COL1,COL2,COL3 * FROM TAB736 * ORDER BY COLK DESC END-EXEC
*Results should be: *2 KILLER HELLAS NEW YORK *1 KILLER HELLAS ATHENS *(All char strings are national char)
DISPLAY"OPEN V;" * EXEC SQL OPEN V; CALL"SUB15"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*now fetch the two rows DISPLAY"FETCH V INTO :colnum, :c1, :c2, :c3;" * EXEC SQL FETCH V INTO :colnum, :c1, :c2, :c3; CALL"SUB16"USING SQLCODE SQLSTATE colnum c1 c2 c3 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"colnum should be 2; its value is ", colnum DISPLAY"c1 should be KILLER; its value is ", c1 DISPLAY"c2 should be HELLAS; its value is ", c2 DISPLAY"c3 should be NEW YORK; its value is ", c3 if (colnum NOT = 2 OR c1 NOT = "KILLER") then MOVE 0 TO flag END-IF if (c2 NOT = "HELLAS"OR c3 NOT = "NEW YORK") then MOVE 0 TO flag END-IF DISPLAY" "
MOVE 0 TO colnum MOVE"xxxxxxxxxxxxxxxxxxx"TO c1 MOVE"xxxxxxxxxxxxxxxxxxx"TO c2 MOVE"xxxxxxxxxxxxxxxxxxx"TO c3
DISPLAY"FETCH V INTO :colnum, :c1, :c2, :c3;" * EXEC SQL FETCH V INTO :colnum, :c1, :c2, :c3; CALL"SUB17"USING SQLCODE SQLSTATE colnum c1 c2 c3 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"colnum should be 1; its value is ", colnum DISPLAY"c1 should be KILLER; its value is ", c1 DISPLAY"c2 should be HELLAS; its value is ", c2 DISPLAY"c3 should be ATHENS; its value is ", c3 if (colnum NOT = 1 OR c1 NOT = "KILLER") then MOVE 0 TO flag END-IF if (c2 NOT = "HELLAS"OR c3 NOT = "ATHENS") then MOVE 0 TO flag END-IF DISPLAY" "
DISPLAY"CLOSE V;" * EXEC SQL CLOSE V; CALL"SUB18"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*now restore the database in its original contents DISPLAY"DROP TABLE TAB736 CASCADE;" * EXEC SQL DROP TABLE TAB736 CASCADE; CALL"SUB20"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
if ( flag = 1 ) then DISPLAY" xts736.mco *** pass *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7036','pass','MCO'); CALL"SUB28"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD else DISPLAY" xts736.mco *** fail *** " * EXEC SQL INSERT INTO CTS1.TESTREPORT * VALUES('7036','fail','MCO'); CALL"SUB29"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
DISPLAY"========================================"
* EXEC SQL COMMIT WORK; CALL"SUB30"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST7036 ********************
**** 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.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.