**************************************************************** * * 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. * * DML098.PCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * This routine tests FIPS sizing for all Dynamic SQL numerics. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * 16.6 Sizing for database constructs * ****************************************************************
MOVE"FLATER "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECT USER INTO :uidx FROM HU.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, dml098.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 TEST0579 ******************* MOVE 1 TO flag
DISPLAY"FETCH BLAT2 INTO :x1, :x2, :x3, :x4;" EXECSQL FETCH BLAT2 INTO :x1, :x2, :x3, :x4 END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"x1 should be 9; its value is ", x1 DISPLAY"x2 should be 9; its value is ", x2 DISPLAY"x3 should be 9; its value is ", x3 DISPLAY"x4 should be 9999; its value is ", x4
if (x1 NOT = 9 OR x2 NOT = 9 OR x3 NOT = 9 OR
x4 NOT = 9999) then MOVE 0 TO flag END-IF
DISPLAY"FETCH BLAT4 INTO :x1, :x2, :x3, :x4;" EXECSQL FETCH BLAT4 INTO :x1, :x2, :x3, :x4 END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY" "
DISPLAY"x1 should be -9; its value is ", x1 DISPLAY"x2 should be -9; its value is ", x2 DISPLAY"x3 should be -9; its value is ", x3 DISPLAY"x4 should be -9999; its value is ", x4
if (x1 NOT = -9 OR x2 NOT = -9 OR x3 NOT = -9 OR
x4 NOT = -9999) then MOVE 0 TO flag END-IF
DISPLAY"dstmt=""SELECT * FROM NUM4 WHERE NUM4C4 < 0""" MOVE"SELECT * FROM NUM4 WHERE NUM4C4 < 0
- " "TO dstmt
DISPLAY"PREPARE S098AA FROM :dstmt;" EXECSQL PREPARE S098AA FROM :dstmt END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C098AA CURSOR FOR S098AA;" EXECSQL DECLARE C098AA CURSOR FOR S098AA END-EXEC
DISPLAY"OPEN C098AA;" EXECSQLOPEN C098AA END-EXEC MOVE SQLCODE TO SQL-COD
COMPUTE x1 = -1 COMPUTE x2 = -1 COMPUTE x3 = -1 COMPUTE x4 = -1 DISPLAY"FETCH C098AA INTO :x1, :x2, :x3, :x4;" EXECSQL FETCH C098AA INTO :x1, :x2, :x3, :x4 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"x1 should be -9; its value is ", x1 DISPLAY"x2 should be -9; its value is ", x2 DISPLAY"x3 should be -9; its value is ", x3 DISPLAY"x4 should be -9999; its value is ", x4
if (x1 NOT = -9 OR x2 NOT = -9 OR x3 NOT = -9 OR
x4 NOT = -9999) then MOVE 0 TO flag END-IF
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST0579 ******************** ******************** BEGIN TEST0580 ******************* MOVE 1 TO flag
*Loss of significant digits is detected using the database's *own equality operator. This should avoid some lossage problems *that affected earlier sizing tests.
*The precise values to which it gets rounded or truncated do *not matter; the test will work as planned provided that the *numbers above and below the target value get the same kind *of treatment. For example, if it gets rounded up to 525000, *the number one greater should also get rounded up to 525000, *and they should pass equality, causing the test to fail. A *similar argument applies to truncation.
*2^28 = 268435456
EXECSQLDELETEFROM CONCATBUF END-EXEC MOVE SQLCODE TO SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES ( 'INSERT INTO NUM5 VALUES (262145E+0,' || ' 262145E+0, 268435457E+0)'
) END-EXEC MOVE SQLCODE TO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVE SQLCODE TO SQL-COD
MOVE 0 TO x1 DISPLAY"FETCH C098BA INTO :x1;" EXECSQL FETCH C098BA INTO :x1 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"x1 should be 1; its value is ", x1 if (x1 NOT = 1) then MOVE 0 TO flag END-IF
*FINIS
DISPLAY"ROLLBACK WORK;" EXECSQL ROLLBACK WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST0580 ******************** ******************** BEGIN TEST0586 ******************* MOVE 1 TO flag
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST0586 ********************
**** 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.
Messung V0.5
¤ Dauer der Verarbeitung: 0.7 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 und die Messung sind noch experimentell.