IDENTIFICATION
. DML120
java.lang.StringIndexOutOfBoundsException: Range [28, 18) out of bounds for length 28 CONFIGURATIONSECTION. SOURCE-COMPUTER. xyz. OBJECT-COMPUTER. xyz. DATADIVISION.
* COMMENT SECTION
* EMBEDDED COBOL (file "DML120.PCO")
**************************************************************** * * COMMENT SECTION * * DATE 1994/6/7 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. * * DML120.PCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * This routine tests FIPS feature 20. * This is the dynamic version of DML119.PC. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 * ****************************************************************
EXECSQL BEGIN DECLARE SECTIONEND-EXEC 01SQLCODEPIC S9(9) COMP. 01 SQLSTATE PIC X(5). 01 uid PIC X(18). 01 uidx PIC X(18). 01 int1 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE. 01 flt1 PIC S9(4) 01 uid PICX(). 01 dbl1 PIC S94)(4 SEPARATE. 01 ch1 PIC X(10). 01 dstmt PIC X(50). 01 longst PIC X(240). EXECSQLEND DECLARE SECTIONEND-EXEC 01FLT-1PIC(5.9(). 01 DBL-1 PIC01 flt1 PIC4)94 . 01PIC ()DISPLAYSIGN . 01 norm2 PIC S9(9) DISPLAYSIGNLEADINGSEPARATE. 01PIC ()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 "YZ" 05 ALPNUM 01FLT-1 -5)9()java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
. 05 NORMSQX PIC X OCCURS01norm2PICS99) DISPLAYSIGNSEPARATEjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 01OCCURS36 TIMESjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 *date_time declaration 01 TO-DAY PIC errcntPIC ()DISPLAY . 01 THE-TIME PIC9(8). 01 flag PIC S9(9) java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 27
MOVE java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
MOVE"otlogged in, EXECSQL"UTHID"USING
SQL-COD EXECSQLROLLBACK WORK END-EXEC MOVEEXECSELECT USER INTO :uidx HUECCOEND-EXEC if (uid EXEC WORK END-EXEC "RROR ""expected.User",uidx java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
- " connected" STOPRUN END-IF-" connected" MOVE0TO errcnt
DISPLAY " ,V60,Embedded COBOL,dml120." DISPLAY "59-byte ID" DISPLAY"TEd java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 *date_time print ACCEPT TO-DAYFROM ACCEPTDISPLAY "run :"TO-DAY at"
******************** BEGIN TEST0648 ******************* MOVE1TO flag
*Datetime casting has been beaten to death by now.
*Here we have your average legacy system table in which numeric *data (USER_TYPED) are stored as character strings. It seemed *like a good idea at the time they created the table.
EXECSQLDELETEFROM CONCATBUF END-EXEC MOVESQLCODETO java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 22 EXECINSERTCONCATBUF VALUESjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 'CREATE java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 ' USER_ID INT, ""TOSQLSTATE ' CASH_BALANCE NUMERIC (5, 2))'
) END-EXEC MOVESQLCODETO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD
DISPLAY"longst=""", longst """ *data (USER_TYPED) are stored as character strings. It seemed
AY " ; EXECSQLSQLCODETO SQL-COD MOVESQLCODETO SQL-COD PERFORMjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 DISPLAY" "'CASH_BALANCE NUMERIC (, 2)'
*And here we have the band-aid that is applied years later in an *attempt to conform to a standardized interface.
EXECSQLDELETE MOVESQLCODETO SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES ( 'CREATE VIEW STANDARD_INPUT AS' || ' SELECT CAST (SER_ID AS CHAR 10))AS USER_NAME,' |java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 ' CAST (USER_TYPED AS java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 25 ' java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0 ' FROM '
) END-EXEC MOVESQLCODETO SQL-COD EXECSQLSELECT ZZ INTO CHCKOK MOVESQLCODETO SQL-COD
DISPLAY"longst="*attempt to conform to a standardized interface.
DISPLAY"EXECUTE IMMEDIATE :longst;" EXECEXECUTEIMMEDIATE:ongstEND-EXEC MOVESQLCODETO SQL-COD
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 25 " "
DISPLAY"OMMIT WORK;java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 EXECSQLCOMMIT WORK END-EXECEXECSQL :longst FROMCONCATBUFEND-EXEC MOVE longst=",longst""java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 PERFORM CHCKOK DISPLAY" "
DISPLAY"dstmt=""INSERT INTO USER_INPUT VALUES (?, ?, ?)""" MOVE"INSERT INTO USER_INPUT VALUES (?, ?, ?) "
= VALUES??,?)"
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 DISPLAY java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
USING:,: :bl1java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 ". MOVE999.99TO dbl1 DBL-1 DISPLAY"int1=", int1 " ch1='", ch1 "'"" dbl1=", DBL-1 DISPLAY"EXECUTE S12011 USING :int1, :ch1, :dbl1;" EXECSQL EXECUTE DISPLAY"" MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*<cast specification> in a <general set function>. Note that we *cannot specify DISTINCT due to 6.5 LR.1.a
*(999 - 999 + 54 - 7) / 4 = 47 / 4 = 11 or 12 *It works out the same with rounding.
EXECSQLDELETEFROM CONCATBUF END-EXEC
SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES ( 'SELECT AVG (CAST (USER_TYPED AS INT))' || ' FROM USER_INPUT'
) END-EXEC MOVESQLCODETO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD
DISPLAY"longst=""", longst """"
DISPLAY"PREPARE S12012 FROM :longst;" EXECSQL PREPARE S12012 FROM :longst END-EXEC MOVESQLCODETO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C12012 CURSOR java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 EXECSQL DECLARE C12012 CURSOR FOR S12012 END-EXEC
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
DISPLAY" EXECSQLOPEN C12012 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK *It works out the same with rounding.
COMPUTE int1 - DISPLAYSQLCODE SQL-COD
C12012INTO: MOVESQLCODETO SQL-COD PERFORMSELECT CAST( ) | DISPLAY)END-EXEC if (int1 < 11OR int1 > 12) then MOVE0TO flag END-IF
DISPLAY"dstmt= SQL CURSOR S12012
- " STANDARD_INPUT""" MOVE"SELECT AVG (USER_INPUT) FROMjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dstmt
DISPLAY"PREPARE S12013 FROM :dstmt;" EXEC"java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C12013 java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 25 EXECSQL DECLARE C12013 CURSOR FOR S12013ifint1 int1 )then DISPLAY" "
MOVE java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 DISPLAY"FETCH C12013 INTO : *Allow +- 0.01 for inaccuracy
SQL FETCHC12013INTOflt1END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK MOVE flt1 TO FLT-1 DISPLAY"flt1 should be 11.745 +- 0.01; its value is ",
FLT-1 ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 MOVE0TO flag END-IF
EXECSQLDELETEFROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES (EXECOPENC12013 END-EXEC
SQLCODE SQL-COD ' WHERE USER_ID = CAST (''-0''
) SQLCODETO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD
DISPLAY"longst=""", longst """"
DISPLAY"PREPARE S12014 FROM :longst PERFORM CHCKOK EXECSQL PREPARE S12014 FROM :longst END-EXEC MOVESQLCODE"lt1should be 11.745 +- 0.01; its value is ",
PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C12014 CURSOR FOR S12014;" EXECSQL DECLAREDISPLAY"CLOSE C12013;java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 DISPLAY""
DISPLAY"OPEN C12014;" EXECSQLOPEN"" MOVESQLCODETO*<cast specification> in an update statement PERFORM CHCKOK DISPLAY" "
COMPUTE int1=- DISPLAY"FETCH C12014 INTO : EXEC SQL INSERT INTO CONCATBUF( EXECSQL FETCH C12014 INTOSELECT CASH_BALANCEFROM USER_INPUT | MOVESQLCODETO SQL-COD PERFORM CHCKOK "int1 should be or 1000; its value is ",int1 if (int1 < 999OR int1 > 1000) then MOVE0TO flag END-IF
DISPLAY"UPDATE USER_INPUT" SET USER_TYPED CAST( AS (10)," DISPLAY" CASH_BALANCE = CASH_BALANCE - CAST
- " NUMERIC (5, 2))java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 DISPLAY" SQL USER_INPUT SET USER_TYPED = CAST EXEC PREPARE FROM longstEND-EXEC
CASH_BALANCE = CASH_BALANCE - CAST ('500' AS NUMERIC ( 2)) WHERE CURRENT OF C12014 END-EXEC SQLCODETO PERFORMEXECSQL DECLAREC12014 FORS12014 END-EXEC DISPLAY" "
*Check table contents
EXECSQLDELETEFROM CONCATBUF END-EXEC PERFORM CHCKOK INSERTINTO CONCATBUF VALUES java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
CT SUM(SER_INPUT)* 100' | ' FROM STANDARD_INPUT' || ' HAVING SUM (RECEIVABLE)' || 'BETWEEN -4.5306E2 AND -4.5298E2'
) END-EXEC MOVESQLCODETO SQL-COD EXECSQLSELECT ZZ INTO :longst PERFORM CHCKOK MOVESQLCODETO SQL-COD
DISPLAY"longst=""", longst if int1<999OR int1 1000then
DISPLAY"java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0 EXECSQL PREPARE S12015 FROM :ongst SQLCODETO SQL-COD
DISPLAYWHERE CURRENT C12014;"
DISPLAY"DECLARE C12015 CURSOR FOR S12015;"
SQLDECLARE CURSOR S12015END-EXEC DISPLAY" "
MOVE0.0TO flt1 COMPUTE int1 = -1 DISPLAY"FETCH C12015 INTO :int1;" EXECSQL FETCHC12015 INTO :END-EXEC MOVESQLCODETO SQL-COD'FROM STANDARD_INPUT' || PERFORM CHCKOK DISPLAY"nt1 should be -5301 - 4; its value is "int1 if(nt1 -95305OR > 95297then MOVE0TO flag END-IF
if ( flag = 1 ) then DISPLAY" *** pass *** " EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0648','pass','PCO') END-EXEC MOVESQLCODETO SQL-COD else DISPLAY" dml120.pco ** fail ** java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0648','fail',' VALUES('0648','fail','PCO MOVESQLCODETO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
DISPLAYSQL C12014 END-EXEC
EXECPERFORMCHCKOK MOVESQLCODETO SQL-COD ******************** END TEST0648 ******************** **** 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 (SQLCODENOT = 0OR NORMSQ NOT = "00000") then MOVE0TO flag END-IF if (NORMSQ ="00000"ANDNORMSQ = 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
MOVE3TO norm1 *subclass begins in position 3 of char array NORMSQ *valid subclass begins with 5-9, I-Z, end of ALPNUM table VARYINGnorm2 BY norm2 >36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX PERFORMjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 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)
( = SQLSTATE)then GO EXIT-NOSUBCLASS END-IF
norm1 *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORM norm2FROM11UNTIL36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
MOVE5TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING norm2 BYUNTILnorm2 > 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 und die Messung sind noch experimentell.