**************************************************************** * * COMMENT SECTION * * DATE 1993/07/13 EMBEDDED COBOL LANGUAGE * NIST SQL VALIDATION TEST SUITE V6.0 * DISCLAIMER: * This program was written by employees of NIST to test SQL * implementations for conformance to the SQL standards. * NIST assumes no responsibility for any party's use of * this program. * * DML097.PCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * This routine tests the INTEGER and SMALLINT data types in * Dynamic SQL. To run this test, you must support features 1 * and 3 for TSQL as listed in FIPS PUB 127-2, or you can avoid * needing feature 3 with TEd changes. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ****************************************************************
* DISCLAIMER:
0 * This program was written by employees of NIST to test SQL
01 SQLSTATE PIC* NIST assumes no responsibility for any party's use of
01 uid PIC X(18).
01 uidx PIC X(18).
01 x1 PIC S9(9) * DML097.PCO
01 x2 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE.
01 x3 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE.
01 dstmt PIC X(50).
01 longst PIC X(240). EXECSQLEND DECLARE SECTIONEND-EXEC * needing feature 3 with TEd changes.
01 norm2 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE.
01 ALPNUM-TABLE VALUE* REFERENCES "01234ABCDEFGH56789IJKLMNOPQRSTUVWXYZ".
05 ALPNUM PIC X OCCURS 36 TIMES.
01 NORMSQ.
05 NORMSQX PIC X OCCURS 5 TIMES.
01 errcnt PIC S9(9) DISPLAYSIGNLEADINGSEPARATE. *date_time declaration
01 TO-DAY PIC 9(6).
01
0 flag S9(9) DISPLAYSIGNLEADINGSEPARATE
01SQL-COD S99 DISPLAYLEADINGSEPARATE.
PROCEDURE0 PIC X(5).
P0
MOVE"FLATER "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECTINTO :uidx HUECCO END-EXEC
01 PIC S99 DISPLAYLEADINGSEPARATE EXECSQL WORK END-EXEC MOVE SQLCODETO
(uid = uidxthen DISPLAY": User " uid expected,uidx
- " connected" STOP . END-IF MOVE 1 norm2 S9(9)DISPLAYLEADINGSEPARATEjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
DISPLAY
OVEloggednot uidx DISPLAYEXECSQL USER : FROM HU END-EXEC "59-byte ID" DISPLAY"TEd Version MOVE SQLCODE TO SQL-COD *date_time print ACCEPT TO-DAY FROMDATE ACCEPT THE-TIME FROMTIME DISPLAYEXECSQL WORK END-EXEC
******************** BEGIN TEST0578 ******************* MOVEifuid = uidx
DISPLAY"ERROR User" uid " expected. ", uidx java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70 DISPLAY" INTEGER and SMALLINT typesin Dynamic SQL" DISPLAY"References:" DISPLAY" FIPS PUB "Test , V6.0, Embedded,dml097"
- " "59byte"
DISPLAYANSI 6.1 <data type DISPLAY" 12.4 Calls to a " *date_time print DISPLAY" - -- - ------"
COMPUTE SQLCODE = -1 MOVE"xxxxx"TO SQLSTATE
*In this test I use SQL arithmetic to avoid conversions between *exact and approximate numerics. However, this arithmetic has *its own implementor-defined precision. I don't expect any vend *will have problems with three significant digits, but in case *they do, you have been warned.
*This is here to avoid language-dependent problems. EXECSQLDELETEFROM CONCATBUF END-EXEC MOVE SQLCODE TO SQL-COD "INTEGER SMALLINTtypes Dynamic SQL" EXECSQLINTO CONCATBUF ( 'CREATE TABLE NUM3 (' || ' NUM3C1 ,' || ' NUM3C2 INT,' -" 1 3" ' NUM3C3 SMALLINT)'
)END-EXEC MOVE SQLCODE TO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVE SQLCODE TO SQL-CODDISPLAY - - ---- ---- - ---- --
DISPLAY"longst=""", longst """"
DISPLAY"COMMIT WORK; MOVE "xxxxTO EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK *will have problems with three significant digits, but in case
DISPLAY"EXECUTE EXEC SQLDELETEFROM END-EXEC EXECSQL EXECUTE IMMEDIATE :longstEND-EXEC MOVE SQLCODEEXECSQLjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
PERFORM DISPLAY SQLCODE SQL-COD
DISPLAY"COMMIT WORK;" "=""", longst MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"dstmt=""INSERT INTO EXEC SQL COMMIT WORK END-EXEC MOVE"INSERT INTO NUM3 VALUES(999,-99,9)
- " "TO dstmt
PERFORM CHCKOK SQLCODETO
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
x2- COMPUTE x3 = -1
DISPLAY"FETCH BLAT2 INTO :x1, :x2, :x3;" EXECSQL java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 21 MOVE SQLCODE TODISPLAY" BLAT1 FROM :dstmt;"
PERFORM CHCKOK DISPLAY"
DISPLAY"CLOSE BLAT2;" PERFORM CHCKOK
OVE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"x1 should be 999; its value is ", x1 DISPLAY"x2 should be -99; its value is ", x2 DISPLAY"x3 should be 9; its value is ", x3
if (x1 NOT = 999 ORMOVETO SQL-COD thenDISPLAY java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 MOVE 0 TO flag END-IF
DISPLAY"dstmt=""DELETE FROM NUM3""" MOVEDELETE TO
DISPLAY"PREPARE WNUM3 FROM :dstmt;" SQL PREPARE FROM : END-EXEC MOVE SQLCODE TO" "
PERFORM CHCKOK ""
DISPLAY"EXECUTE WNUM3;"
SQLCODETO SQL-COD MOVE
DISPLAY"dstmt=""INSERT INTO NUM3 VALUES (0, 0, 0.1)""" INTO NUM3 (0, 0, 0.) " TO dstmt
PERFORM " java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
DISPLAY"OPEN BLAT2;" EXECSQLOPEN 0 TO flag MOVE SQLCODEEND-IF
PERFORM CHCKOK DISPLAY" "
COMPUTEDISPLAY"=""DELETE FROM NUM3""" COMPUTEMOVEDELETE java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 COMPUTE x3 = -1
DISPLAY"FETCH BLAT2 INTO :x1, :x2, :x3;" EXECSQL FETCH BLAT2 INTO :x1, :x2, :x3 SQLCODE SQL-COD MOVESQLCODE TO
PERFORM DISPLAY" "
DISPLAY"CLOSE BLAT2;" EXECSQL BLAT2 MOVE SQLCODE TO SQL-CODMOVETO SQL-COD
PERFORM CHCKOK DISPLAY" "
"INSERT INTO NUM3 VALUES(0 0,01) " DISPLAY x2 0 value, java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
ISPLAY shouldbe its is", x3
if (x1 NOT = 0 OR x2 NOT = 0 OR x3 NOT = 0) thenEXECSQL EXECUTE :dstmt MOVE 0 TO flag END-IFDISPLAY" BLAT2;"
DISPLAY"dstmt=""DROP TABLE NUM3 CASCADE""" "DROP TABLE CASCADE " TO dstmt
DISPLAY"EXECUTE IMMEDIATE :dstmt;" EXECSQL IMMEDIATE dstmt MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
EXECOPENEND-EXEC EXEC COMMIT END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
if ( flag = 1 ) then DISPLAY" ***java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 28 EXECSQLINSERTINTO HUEXEC FETCH BLAT2 INTO x1x2, :x3
VALUES('0578','pass','PCO') END-EXEC " else" ;" EXECCLOSE BLAT2 EXECINSERTINTO.TESTREPORT
VALUES( CHCKOK " " COMPUTE errcnt = errcnt + 1 END-IF
"=============================="
EXECSQL COMMIT WORK END-EXEC
ETO ******************** END TEST0578 ********************
**** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0 STOPRUN.
* **** Procedures for PERFORM statements
*Test SQLCODE and SQLSTATE for normal completion.
CHCKOK SQLROLLBACK END-EXEC DISPLAY" should be 0;its value is ", SQL-COD DISPLAY PERFORM THRU EXIT-NOSUBCLASS if(SQLCODE NOT 0ORNOT = "0000"then MOVETO END-IF if (NORMSQ = "00 DISPLAY"XECUTE:;java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 then DISPLAY"Valid OVESQLCODE TO SQL-COD 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 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
n 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 4TO *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORM OMPUTE = errcnt 1 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0" DISPLAY "====================java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 END-IF END-PERFORM
MOVE 5 TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING* **** Procedures for PERFORM statements if 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) (SQLCODE = 0 ORNOT = "000"then MOVE"0"TO NORMSQX(2) END-IF then
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.