*Copyright 1996 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 * * YTS778.PCO * WRITTEN BY: Susan Watters * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * ALTER TABLE SET COLUMN DEFAULT * * * REFERENCES * 11.12 <alter column definition> * 11.13 <set column default clause> * 11.5 GR2 <default clause> * F#38 Schema manipulation * F#3 Basic schema manipulation * F#25 Domain definition * * DATE LAST ALTERED 02.01.96 CTS5 Hand-over Test * * QA Status: Full FC * * Revised by DWF 1996-03-15 * Added rollback after authid * Fixed SDL transactions * Cleanup * More output * Corrected expected results * Initialized vars * Fixed cursor usage * Drop table, domains at end of test ****************************************************************
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, yts778.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 TEST7520 ******************* MOVE 1 TO flag
*Create domain with default clause DISPLAY"CREATE DOMAIN int_dom2 AS INTEGER;" DISPLAY" DEFAULT 99;" EXECSQL CREATE DOMAIN int_dom2 AS INTEGER
DEFAULT 99 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Create table alt_test
DISPLAY"CREATE TABLE alt_test" DISPLAY"( K integer," DISPLAY" L integer DEFAULT 50," DISPLAY" M integer," DISPLAY" N int_dom2);" EXECSQL CREATE TABLE alt_test
( K integer,
L integer DEFAULT 50,
M integer,
N int_dom2) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO alt_test VALUES (1,1,1,1);" EXECSQLINSERTINTO alt_test VALUES (1,1,1,1) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO alt_test (K,L,N) VALUES (2,2,2);" EXECSQLINSERTINTO alt_test (K,L,N) VALUES (2,2,2) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO alt_test (K,M) VALUES (3,3);" EXECSQLINSERTINTO alt_test (K,M) VALUES (3,3) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*declare cursor to retrieve values from alt_test
DISPLAY"DECLARE data78 SCROLL CURSOR FOR" DISPLAY"SELECT * FROM alt_test" DISPLAY"ORDER BY K;" EXECSQL DECLARE data78 SCROLL CURSOR FOR SELECT * FROM alt_test ORDERBY K END-EXEC
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col3 MOVE 99 TO col4 DISPLAY"Retrieve all three rows from the table" DISPLAY"FETCH FIRST data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH FIRST data78 INTO :col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 1; its value is ", col1 DISPLAY"col2 should be 1; its value is ", col2 DISPLAY"col3 should be 1; its value is ", col3 DISPLAY"col4 should be 1; its value is ", col4 if (col1 NOT = 1 OR col2 NOT = 1 OR col3 NOT = 1 OR col4 NOT = 1) then MOVE 0 TO flag END-IF
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col4 MOVE 99 TO indic1 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3:indic1,
- " :col4;" EXECSQL FETCH NEXT data78 INTO :col1,
:col2, :col3:indic1, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 2; its value is ", col1 DISPLAY"col2 should be 2; its value is ", col2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"col4 should be 2; its value is ", col4 if (col1 NOT = 2 OR col2 NOT = 2 OR indic1 NOT =
-1 OR col4 NOT = 2) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 3; its value is ", col1 DISPLAY"col2 should be 50; its value is ", col2 DISPLAY"col3 should be 3; its value is ", col3 DISPLAY"col4 should be 99; its value is ", col4 if (col1 NOT = 3 OR col2 NOT = 50 OR col3 NOT = 3 OR col4 NOT = 99) then MOVE 0 TO flag END-IF
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"Alter column default for each column"
DISPLAY"ALTER TABLE alt_test ALTER COLUMN L SET DEFAULT
- " 100;" EXECSQLALTER TABLE alt_test ALTERCOLUMN L SET DEFAULT
100 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"ALTER TABLE alt_test ALTER COLUMN M SET DEFAULT
- " 90;" EXECSQLALTER TABLE alt_test ALTERCOLUMN M SET DEFAULT 90 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Column default takes precedence over domain default
DISPLAY"ALTER TABLE alt_test ALTER COLUMN N SET DEFAULT
- " 80;" EXECSQLALTER TABLE alt_test ALTERCOLUMN N SET DEFAULT 80 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col3 MOVE 99 TO col4 DISPLAY"Retrieve all three rows from the table" DISPLAY"FETCH FIRST data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH FIRST data78 INTO :col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 1; its value is ", col1 DISPLAY"col2 should be 1; its value is ", col2 DISPLAY"col3 should be 1; its value is ", col3 DISPLAY"col4 should be 1; its value is ", col4 if (col1 NOT = 1 OR col2 NOT = 1 OR col3 NOT = 1 OR col4 NOT = 1) then MOVE 0 TO flag END-IF
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col4 MOVE 99 TO indic1 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3:indic1,
- " :col4;" EXECSQL FETCH NEXT data78 INTO :col1,
:col2, :col3:indic1, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 2; its value is ", col1 DISPLAY"col2 should be 2; its value is ", col2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"col4 should be 2; its value is ", col4 if (col1 NOT = 2 OR col2 NOT = 2 OR indic1 NOT =
-1 OR col4 NOT = 2) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 3; its value is ", col1 DISPLAY"col2 should be 50; its value is ", col2 DISPLAY"col3 should be 3; its value is ", col3 DISPLAY"col4 should be 99; its value is ", col4 if (col1 NOT = 3 OR col2 NOT = 50 OR col3 NOT = 3 OR col4 NOT = 99) then MOVE 0 TO flag END-IF
DISPLAY"Insert three more rows into the table" DISPLAY"INSERT INTO alt_test VALUES (4,4,4,4);" EXECSQLINSERTINTO alt_test VALUES (4,4,4,4) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO alt_test(K,L) VALUES (5,5);" EXECSQLINSERTINTO alt_test(K,L) VALUES (5,5) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO alt_test(K,M) VALUES (6,6);" EXECSQLINSERTINTO alt_test(K,M) VALUES (6,6) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"Retrieve all six rows from the table"
*Changes won't necessarily be visible until cursor is re-opened
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col3 MOVE 99 TO col4 DISPLAY"FETCH FIRST data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH FIRST data78 INTO :col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 1; its value is ", col1 DISPLAY"col2 should be 1; its value is ", col2 DISPLAY"col3 should be 1; its value is ", col3 DISPLAY"col4 should be 1; its value is ", col4 if (col1 NOT = 1 OR col2 NOT = 1 OR col3 NOT = 1 OR col4 NOT = 1) then MOVE 0 TO flag END-IF
MOVE 99 TO col1 MOVE 99 TO col2 MOVE 99 TO col4 MOVE 99 TO indic1 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3:indic1,
- " :col4;" EXECSQL FETCH NEXT data78 INTO :col1,
:col2, :col3:indic1, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 2; its value is ", col1 DISPLAY"col2 should be 2; its value is ", col2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"col4 should be 2; its value is ", col4 if (col1 NOT = 2 OR col2 NOT = 2 OR indic1 NOT =
-1 OR col4 NOT = 2) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 3; its value is ", col1 DISPLAY"col2 should be 50; its value is ", col2 DISPLAY"col3 should be 3; its value is ", col3 DISPLAY"col4 should be 99; its value is ", col4 if (col1 NOT = 3 OR col2 NOT = 50 OR col3 NOT = 3 OR col4 NOT = 99) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 4; its value is ", col1 DISPLAY"col2 should be 4; its value is ", col2 DISPLAY"col3 should be 4; its value is ", col3 DISPLAY"col4 should be 4; its value is ", col4 if (col1 NOT = 4 OR col2 NOT = 4 OR col3 NOT = 4 OR col4 NOT = 4) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 5; its value is ", col1 DISPLAY"col2 should be 5; its value is ", col2 DISPLAY"col3 should be 90; its value is ", col3 DISPLAY"col4 should be 80; its value is ", col4 if (col1 NOT = 5 OR col2 NOT = 5 OR col3 NOT = 90 OR col4 NOT = 80) then MOVE 0 TO flag END-IF
MOVE 0 TO col1 MOVE 0 TO col2 MOVE 0 TO col3 MOVE 0 TO col4 DISPLAY"FETCH NEXT data78 INTO :col1, :col2, :col3,
- " :col4;" EXECSQL FETCH NEXT data78 INTO
:col1, :col2, :col3, :col4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"col1 should be 6; its value is ", col1 DISPLAY"col2 should be 100; its value is ", col2 DISPLAY"col3 should be 6; its value is ", col3 DISPLAY"col4 should be 80; its value is ", col4 if (col1 NOT = 6 OR col2 NOT = 100 OR col3 NOT =
6 OR col4 NOT = 80) then MOVE 0 TO flag END-IF
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST7520 ********************
**** 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.17 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.