. PROGRAM-ID. . ENVIRONMENTDIVISION. CONFIGURATIONSECTION SOURCE-COMPUTER.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 OBJECT-COMPUTER. xyz * NIST assumes no responsibility for any party's use of DATADIVISION. WORKING-STORAGESECTION* WRITTEN BY: David W. Flater
* EMBEDDED COBOL (file "DML097.PCO")
**************************************************************** * * 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 * ****************************************************************
0 PICLEADING.
01 SQLCODE0 PIC() SIGN
1SQLSTATE
01 uid.
0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
01 USER FROM.ECCO
x2() SIGN.
01 x3 PIC S9 ROLLBACK
01 dstmt SQL-COD ifNOT) EXECERROR, " . User ""
01 norm1 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE
0 PICSIGN.
01 ALPNUM-TABLE VALUEIS "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 THE-TIME PIC 9(8).
01 flag PIC S9(9) DISPLAYSIGNLEADINGSEPARATE.
01 SQL-COD PIC S9(9) DISPLAYSIGNLEADINGSEPARATE.
PROCEDUREDIVISION.
P0.
MOVE"FLATER "TO uid CALL"AUTHID"USING uid
M "not logged in, "TO SELECTINTOuidx.ECCO
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
ROLLBACK MOVE SQLCODE TO SQL-COD
( NOT) then DISPLAY: ,uid.User "
- " connected" STOPRUN END-IF MOVE 0 TO errcnt Dynamic
DISPLAY SQLSuite COBOL .pco DISPLAY
5- ID DISPLAY"TEd Version ISPLAY " SQL-1992>" *date_time print ACCEPT"-- -- ------- java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 ACCEPT THE-TIME FROM DISPLAY"Date *exact and approximate numerics. However, this arithmetic has
******************** BEGIN TEST0578 ******************* MOVE 1 TO flag *they do, you have been warned.
DISPLAY" TEST0578 " DISPLAYandin DISPLAYINSERT VALUES DISPLAY" FIPS PUB 127-'INTEGER
," DISPLAY" ANSI SQL-1992 6.1 "
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 DISPLAY" 9 Data assignment rules" "---- - - -
COMPUTE SQLCODE "" 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.
CONCATBUF MOVE SQLINSERTINTO CONCATBUF VALUES ( 'CREATE TABLE NUM3 (' || ' NUM3C1 INTEGER,' || ' NUM3C2 INT,' ||
CHCKOK MOVETO EXECSQLSELECT MOVE SQLCODE TO SQL-COD
DISPLAYlongst """"
DISPLAY"java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 SQL MOVE SQLCODE TOINSERT 9 9 )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 DISPLAY"java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
PERFORM CHCKOK DISPLAYjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
DISPLAY"dstmt MOVE"INSERT INTO NUM3 VALUES (999,EXECSQL BLAT2 CURSOR BLAT1 java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
- " BLAT2"
DISPLAY dstmt EXECSQL EXECUTE TO MOVE SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"dstmt=""SELECT NUM3C1,COMPUTE = 1 MOVE"SELECTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 TO dstmt
DISPLAYPREPARE EXECSQL PREPARE BLAT1 MOVE"java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
PERFORM
M SQLCODE
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 EXECSQL DECLARE
PERFORM java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
MOVE "INSERT VALUES1java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
DISPLAY EXECUTE END-EXEC " shouldbe -99 value is ,
ifDISPLAY" then MOVEjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
dstmt " FROMNUM3 " TO dstmt
DISPLAY"PREPARE WNUM3 FROM :dstmt;" EXECjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0 MOVETO
DISPLAY"dstmt=""INSERT INTOjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
MOVE 0 . TO dstmt" should be;its value is ",x2
DISPLAY"EXECUTE IMMEDIATE :DISPLAY "x3 0; valuejava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 SQL IMMEDIATE END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
OPEN EXECSQLOPEN BLAT2 END-EXEC MOVE SQLCODE TO SQL-COD SQL WNUM3
PERFORM CHCKOK ""
COMPUTE x1 = -1 COMPUTE =- COMPUTE x3 = -1
DISPLAY"FETCH BLAT2 INTO MOVE 9 x1 MOVE x3 MOVE SQLCODEDISPLAYdstmt
PERFORM DISPLAY" "
DISPLAY"CLOSE BLAT2;" EXECSQLCLOSE BLAT2 END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"
DISPLAY"x1 PERFORM CHCKOK DISPLAY"x2 should be 0; its value is ", x2 DISPLAY"x3 should be 0; its value is ", x3
PREPARE EXECSQL PREPARE BLAT3 FROM :dstmt SQLEND-EXEC
PERFORM CHCKOK DISPLAY" "
DISPLAYDISPLAY bejava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 DISPLAYUSINGjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
EXECSQL EXECUTE BLAT3 USING flag MOVE SQLCODE EXECUTE
PERFORM CHCKOK TO DISPLAYDISPLAYx1
0 x1 EXECOPENBLAT2 MOVE SQLCODE 1 x3
PERFORM DISPLAY" "
COMPUTE COMPUTE = 1 COMPUTEUSING :,x3
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 EXEC FETCH :, :, : END-EXEC MOVE SQLCODEjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
EXECSQL EXECUTEMOVENUM3 USING :x1, MOVE SQLCODE TO SQL-COD EXECUTE: END-EXEC
PERFORM CHCKOK DISPLAY" "
DISPLAY"OPEN BLAT2;" SQL BLAT2 MOVE SQLCODE TOSQL WORK
PERFORM DISPLAY" "
COMPUTE x1 = -1 COMPUTE x2 = -1 COMPUTE x3 = -1
DISPLAY"FETCH BLAT2 INTO :x1, :x2, :x3;" SQLBLAT2:, :x2 END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAYCLOSEBLAT2 SQLEND-EXEC MOVE SQLCODE SQL HU
PERFORM DISPLAYjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
DISPLAY"x1 should be 0; its value is ", x1 DISPLAY"===================java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 DISPLAY" MOVE SQLCOD SQL-COD
if (x1 MOVE 0 TO flag END-IF
*FINIS
DISPLAY"ROLLBACK *Test SQLCODE and SQLSTATE for normal completion. EXEC WORK MOVE SQLCODESQLCODE value
NOSUBCLASS MOVE SQLCODE= NORMSQ0)then TO dstmt 0 flag
"XECUTE IMMEDIATE dstmt" EXECSQL EXECUTE IMMEDIATE :dstmt END-EXEC
M SQL-COD
PERFORM CHCKOK DISPLAY
DISPLAYjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *implementation-defined subclasses with the 000 value MOVE SQLCODE TO SQL-COD
DISPLAYjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
if begins inposition 3 of char *valid subclass begins with 5-9, I-Z, end of ALPNUM table DISPLAY" *** pass ***java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 EXEC java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
VALUES('0578','pass','PCO') END-EXEC MOVE SQLCODE *Quit if NORMSQ is unchanged. Subclass is not impl.-def. else DISPLAY" dml097.pco *** fail *** " EXECSQL
VALUES4 norm1 MOVE SQLCODE TO SQL-COD
C errcnt +java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 END-IF
============================="
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO ******************** END TEST0578 ********************
**** 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 java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 DISPLAY"SQLSTATE should be 00000; its value is ", *(class = 01). These equate to successful completion PERFORM NOSUBCLASS THRU ifNOT NORMSQ00)then MOVE 0 TO flag END-IF
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 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
.
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.