**************************************************************** * * COMMENT SECTION * * DATE 1994/8/30 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. * * DML135.PCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * This program tests multiple TSQL features together. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 * ****************************************************************
MOVE"FLATER "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECT USER INTO :uidx FROM HU.ECCO END-EXEC MOVESQLCODETO SQL-COD EXECSQLROLLBACK WORK END-EXEC MOVESQLCODETO 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, dml135.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 TEST0692 ******************* MOVE 1 TO flag
DISPLAY"INSERT INTO ""Works""" DISPLAY" SELECT * FROM Hu.Works;" EXECSQLINSERTINTO"Works" SELECT * FROM Hu.Works END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13511 CURSOR FOR" DISPLAY" SELECT * FROM PTYPES ORDER BY NUM;" EXECSQL DECLARE C13511 CURSOR FOR SELECT * FROM PTYPES ORDERBY NUM END-EXEC
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tchar should be 'Test '; its value is '",
tchar "'" DISPLAY"int1 should be 2; its value is ", int1 if (tchar NOT = "Test "OR int1 NOT = 2) then MOVE 0 TO flag END-IF
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tchar should be 'Design'; its value is '",
tchar "'" DISPLAY"int1 should be 3; its value is ", int1 if (tchar NOT = "Design"OR int1 NOT = 3) then MOVE 0 TO flag END-IF
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tchar should be 'Code '; its value is '",
tchar "'" DISPLAY"int1 should be 4; its value is ", int1 if (tchar NOT = "Code "OR int1 NOT = 4) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
EXECSQLDELETEFROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES ( 'SELECT NUM, COUNT(*) FROM "PStaff"' || ' GROUP BY NUM ORDER BY NUM'
) END-EXEC MOVESQLCODETO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVESQLCODETO SQL-COD
DISPLAY"longst=""", longst """"
DISPLAY"PREPARE S13512 FROM :longst;" EXECSQL PREPARE S13512 FROM :longst END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13512 CURSOR FOR S13512;" EXECSQL DECLARE C13512 CURSOR FOR S13512 END-EXEC
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 1; its value is ", int1 DISPLAY"int2 should be 2; its value is ", int2 if (int1 NOT = 1 OR int2 NOT = 2) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 2; its value is ", int1 DISPLAY"int2 should be 2; its value is ", int2 if (int1 NOT = 2 OR int2 NOT = 2) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 4; its value is ", int1 DISPLAY"int2 should be 1; its value is ", int2 if (int1 NOT = 4 OR int2 NOT = 1) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tchar should be 'Test '; its value is '",
tchar "'" DISPLAY"int1 should be 2; its value is ", int1 if (tchar NOT = "Test "OR int1 NOT = 2) then MOVE 0 TO flag END-IF
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tchar should be 'Code '; its value is '",
tchar "'" DISPLAY"int1 should be 4; its value is ", int1 if (tchar NOT = "Code "OR int1 NOT = 4) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13511 INTO :tchar, :int1;" EXECSQL FETCH C13511 INTO :tchar, :int1 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 1; its value is ", int1 DISPLAY"int2 should be 2; its value is ", int2 if (int1 NOT = 1 OR int2 NOT = 2) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 4; its value is ", int1 DISPLAY"int2 should be 1; its value is ", int2 if (int1 NOT = 4 OR int2 NOT = 1) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13512 INTO :int1, :int2;" EXECSQL FETCH C13512 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
EXECSQLCOMMIT WORK END-EXEC MOVESQLCODETO SQL-COD ******************** END TEST0692 ******************** ******************** BEGIN TEST0693 ******************* MOVE 1 TO flag
MOVE 99 TO int1 MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'CREATIONTIMES '; its value is
- " '", tname "'" DISPLAY"ttype should be 'BASE TABLE'; its value is '",
ttype "'" DISPLAY"cname should be 'CREATE_TIME '; its value is
- " '", cname "'" DISPLAY"int1 should be 16; its value is ", int1 DISPLAY"indic1 should be 0; its value is ", indic1 if (tname NOT = "CREATIONTIMES ") then MOVE 0 TO flag END-IF if (ttype NOT = "BASE TABLE") then MOVE 0 TO flag END-IF if (cname NOT = "CREATE_TIME ") then MOVE 0 TO flag END-IF if (int1 NOT = 16 OR indic1 NOT = 0) then MOVE 0 TO flag END-IF
MOVE 99 TO int1 MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'CREATIONTIMES '; its value is
- " '", tname "'" DISPLAY"ttype should be 'BASE TABLE'; its value is '",
ttype "'" DISPLAY"cname should be 'TABLE_NAME '; its value is
- " '", cname "'" DISPLAY"int1 should be 16; its value is ", int1 DISPLAY"indic1 should be 0; its value is ", indic1 if (tname NOT = "CREATIONTIMES ") then MOVE 0 TO flag END-IF if (ttype NOT = "BASE TABLE") then MOVE 0 TO flag END-IF if (cname NOT = "TABLE_NAME ") then MOVE 0 TO flag END-IF if (int1 NOT = 16 OR indic1 NOT = 0) then MOVE 0 TO flag END-IF
MOVE 99 TO int1 MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'CREATIONTIMES '; its value is
- " '", tname "'" DISPLAY"ttype should be 'BASE TABLE'; its value is '",
ttype "'" DISPLAY"cname should be 'TABLE_SCHEM '; its value is
- " '", cname "'" DISPLAY"int1 should be 16; its value is ", int1 DISPLAY"indic1 should be 0; its value is ", indic1 if (tname NOT = "CREATIONTIMES ") then MOVE 0 TO flag END-IF if (ttype NOT = "BASE TABLE") then MOVE 0 TO flag END-IF if (cname NOT = "TABLE_SCHEM ") then MOVE 0 TO flag END-IF if (int1 NOT = 16 OR indic1 NOT = 0) then MOVE 0 TO flag END-IF
MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'TABLESCOLUMNS '; its value is
- " '", tname "'" DISPLAY"ttype should be 'VIEW '; its value is '",
ttype "'" DISPLAY"cname should be 'COLUMN_NAME '; its value is
- " '", cname "'" DISPLAY"indic1 should be -1; its value is ", indic1 if (tname NOT = "TABLESCOLUMNS ") then MOVE 0 TO flag END-IF if (ttype NOT = "VIEW ") then MOVE 0 TO flag END-IF if (cname NOT = "COLUMN_NAME ") then MOVE 0 TO flag END-IF if (indic1 NOT = -1) then MOVE 0 TO flag END-IF
MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'TABLESCOLUMNS '; its value is
- " '", tname "'" DISPLAY"ttype should be 'VIEW '; its value is '",
ttype "'" DISPLAY"cname should be 'CREATE_TIME '; its value is
- " '", cname "'" DISPLAY"indic1 should be -1; its value is ", indic1 if (tname NOT = "TABLESCOLUMNS ") then MOVE 0 TO flag END-IF if (ttype NOT = "VIEW ") then MOVE 0 TO flag END-IF if (cname NOT = "CREATE_TIME ") then MOVE 0 TO flag END-IF if (indic1 NOT = -1) then MOVE 0 TO flag END-IF
MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'TABLESCOLUMNS '; its value is
- " '", tname "'" DISPLAY"ttype should be 'VIEW '; its value is '",
ttype "'" DISPLAY"cname should be 'TABLE_NAME '; its value is
- " '", cname "'" DISPLAY"indic1 should be -1; its value is ", indic1 if (tname NOT = "TABLESCOLUMNS ") then MOVE 0 TO flag END-IF if (ttype NOT = "VIEW ") then MOVE 0 TO flag END-IF if (cname NOT = "TABLE_NAME ") then MOVE 0 TO flag END-IF if (indic1 NOT = -1) then MOVE 0 TO flag END-IF
MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'TABLESCOLUMNS '; its value is
- " '", tname "'" DISPLAY"ttype should be 'VIEW '; its value is '",
ttype "'" DISPLAY"cname should be 'TABLE_SCHEM '; its value is
- " '", cname "'" DISPLAY"indic1 should be -1; its value is ", indic1 if (tname NOT = "TABLESCOLUMNS ") then MOVE 0 TO flag END-IF if (ttype NOT = "VIEW ") then MOVE 0 TO flag END-IF if (cname NOT = "TABLE_SCHEM ") then MOVE 0 TO flag END-IF if (indic1 NOT = -1) then MOVE 0 TO flag END-IF
MOVE 99 TO indic1 MOVE"xxxxxxxxxxxxxxxxxx"TO tname MOVE"xxxxxxxxxx"TO ttype MOVE"xxxxxxxxxxxxxxxxxx"TO cname DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"tname should be 'TABLESCOLUMNS '; its value is
- " '", tname "'" DISPLAY"ttype should be 'VIEW '; its value is '",
ttype "'" DISPLAY"cname should be 'TABLE_TYPE '; its value is
- " '", cname "'" DISPLAY"indic1 should be -1; its value is ", indic1 if (tname NOT = "TABLESCOLUMNS ") then MOVE 0 TO flag END-IF if (ttype NOT = "VIEW ") then MOVE 0 TO flag END-IF if (cname NOT = "TABLE_TYPE ") then MOVE 0 TO flag END-IF if (indic1 NOT = -1) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13521" DISPLAY" INTO :tname, :ttype, :cname, :int1:indic1;" EXECSQL FETCH C13521 INTO :tname, :ttype, :cname, :int1:indic1 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"INSERT INTO CREATIONTIMES VALUES" DISPLAY" ('FLATER', 'USIG', DEFAULT);" EXECSQLINSERTINTO CREATIONTIMES VALUES
('FLATER', 'USIG', DEFAULT) END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 25000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT < 0 OR NORMSQ NOT = "25000") then MOVE 0 TO flag END-IF if (NORMSQ = "25000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
EXECSQLCOMMIT WORK END-EXEC MOVESQLCODETO SQL-COD ******************** END TEST0693 ******************** ******************** BEGIN TEST0694 ******************* MOVE 1 TO flag
*you have: approximate numeric *you want: interval hour to minute *You can't cast an approximate numeric as an interval (6.10 SR.4
*you have: exact numeric *you want: interval hour to minute *You can't cast an exact numeric as an interval with more than o *<datetime field> (6.10 SR.5).
* This is how you do it: *1.9 * INTERVAL '1:00' HOUR TO MINUTE
*If you've only got one <datetime field> you can do this: * CAST (CAST (1.9 AS NUMERIC (2, 1)) AS INTERVAL SECOND) *but you're probably still better off to say * 1.9 * INTERVAL '1.000000' SECOND
DISPLAY"CREATE VIEW PROJ_HOURS (PNUM, HOURS) AS" DISPLAY" SELECT PNUM, AVG (HOURS) * INTERVAL '01:00' HOUR
- " TO MINUTE" DISPLAY" FROM WORKS GROUP BY PNUM;" EXECSQL CREATE VIEW PROJ_HOURS (PNUM, HOURS) AS SELECT PNUM, AVG (HOURS) * INTERVAL '01:00' HOUR TO
MINUTE FROM WORKS GROUP BY PNUM END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE VIEW PROJ_HOURS2 (PNUM, HOURS) AS" DISPLAY" SELECT PNUM," DISPLAY" AVG (CAST (CAST (HOURS AS INTERVAL HOUR)" DISPLAY" AS INTERVAL HOUR TO MINUTE))" DISPLAY" FROM WORKS GROUP BY PNUM;" EXECSQL CREATE VIEW PROJ_HOURS2 (PNUM, HOURS) AS SELECT PNUM,
AVG (CAST (CAST (HOURS AS INTERVAL HOUR)
AS INTERVAL HOUR TO MINUTE)) FROM WORKS GROUP BY PNUM END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*The views PROJ_HOURS and PROJ_HOURS2 should be equivalent *modulo any roundoff or truncation error.
*Allowing the sign to move inside of the quotes: TC #2 5.3 *( datetime - datetime ) <interval qualifier>: 6.15 FT.1 *Comparability of HOUR TO MINUTE vs. MINUTE: 4.5.2
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM PROJ_HOURS A, PROJ_HOURS2 B" DISPLAY" WHERE A.PNUM = B.PNUM" DISPLAY" AND (A.HOURS - B.HOURS) HOUR TO MINUTE" DISPLAY" BETWEEN INTERVAL '-1' MINUTE AND INTERVAL '+1'
- " MINUTE;" EXECSQLSELECTCOUNT(*) INTO :int1 FROM PROJ_HOURS A, PROJ_HOURS2 B WHERE A.PNUM = B.PNUM AND (A.HOURS - B.HOURS) HOUR TO MINUTE
BETWEEN INTERVAL '-1' MINUTE AND INTERVAL '+1' MINUTE END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 6; its value is ", int1 if (int1 NOT = 6) then MOVE 0 TO flag END-IF
*The views TYPE_TIMES and TYPE_TIMES2 should be equivalent *modulo any roundoff or truncation error.
COMPUTE int1 = -1 DISPLAY"SELECT COUNT(*) INTO :int1" DISPLAY" FROM TYPE_TIMES A, TYPE_TIMES2 B" DISPLAY" WHERE A.JOB_TYPE = B.JOB_TYPE" DISPLAY" AND (A.RUN_SECONDS - B.RUN_SECONDS) SECOND" DISPLAY" BETWEEN INTERVAL '-00.000010' SECOND" DISPLAY" AND INTERVAL '+00.000010' SECOND;" EXECSQLSELECTCOUNT(*) INTO :int1 FROM TYPE_TIMES A, TYPE_TIMES2 B WHERE A.JOB_TYPE = B.JOB_TYPE AND (A.RUN_SECONDS - B.RUN_SECONDS) SECOND
BETWEEN INTERVAL '-00.000010' SECOND AND INTERVAL '+00.000010' SECOND END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 2; its value is ", int1 if (int1 NOT = 2) then MOVE 0 TO flag END-IF
*Check contents of PROJ_HOURS
DISPLAY"DECLARE C13531 CURSOR FOR" DISPLAY" SELECT EXTRACT (HOUR FROM HOURS)," DISPLAY" EXTRACT (MINUTE FROM HOURS)" DISPLAY" FROM PROJ_HOURS ORDER BY PNUM;" EXECSQL DECLARE C13531 CURSOR FOR SELECT EXTRACT (HOUR FROM HOURS),
EXTRACT (MINUTE FROM HOURS) FROM PROJ_HOURS ORDERBY PNUM END-EXEC
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 43; its value is ", int1 DISPLAY"int2 should be 20; its value is ", int2 if (int1 NOT = 43) then MOVE 0 TO flag END-IF if (int2 < 19 OR int2 > 20) then MOVE 0 TO flag END-IF if (flag = 1 AND int2 = 19) then DISPLAY"truncation/roundoff error for int2 OK" END-IF DISPLAY" "
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 35; its value is ", int1 DISPLAY"int2 should be 0; its value is ", int2 if (int1 NOT = 35 OR int2 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 52; its value is ", int1 DISPLAY"int2 should be 30; its value is ", int2 if (int1 NOT = 52 OR int2 NOT = 30) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 30; its value is ", int1 DISPLAY"int2 should be 0; its value is ", int2 if (int1 NOT = 30 OR int2 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 46; its value is ", int1 DISPLAY"int2 should be 0; its value is ", int2 if (int1 NOT = 46 OR int2 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 12; its value is ", int1 DISPLAY"int2 should be 0; its value is ", int2 if (int1 NOT = 12 OR int2 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13531 INTO :int1, :int2;" EXECSQL FETCH C13531 INTO :int1, :int2 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"DECLARE C13532 CURSOR FOR" DISPLAY" SELECT EXTRACT (SECOND FROM RUN_SECONDS)" DISPLAY" FROM TYPE_TIMES ORDER BY JOB_TYPE;" EXECSQL DECLARE C13532 CURSOR FOR SELECT EXTRACT (SECOND FROM RUN_SECONDS) FROM TYPE_TIMES ORDERBY JOB_TYPE END-EXEC
COMPUTE flt1 = -1.0 DISPLAY"FETCH C13532 INTO :flt1;" EXECSQL FETCH C13532 INTO :flt1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"flt1 should be 10.993333 +- 0.00001; its value is
- " ", flt1 if (flt1 < 10.993323 OR flt1 > 10.993343) then MOVE 0 TO flag END-IF
COMPUTE flt1 = -1.0 DISPLAY"FETCH C13532 INTO :flt1;" EXECSQL FETCH C13532 INTO :flt1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"flt1 should be 0.855 +- 0.00001; its value is ",
flt1 if (flt1 < 0.85499 OR flt1 > 0.85501) then MOVE 0 TO flag END-IF
DISPLAY"FETCH C13532 INTO :flt1;" EXECSQL FETCH C13532 INTO :flt1 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be 100; its value is ", SQL-COD DISPLAY"SQLSTATE should be 02000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 100 OR NORMSQ NOT = "02000") then MOVE 0 TO flag END-IF if (NORMSQ = "02000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
COMPUTE int1 = -1 DISPLAY"SELECT EXTRACT (DAY FROM WORKTOTL)" DISPLAY" INTO :int1 FROM HUNDREDS;" EXECSQLSELECT EXTRACT (DAYFROM WORKTOTL) INTO :int1 FROM HUNDREDS END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 0; its value is ", int1 if (int1 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT EXTRACT (HOUR FROM WORKTOTL)" DISPLAY" INTO :int1 FROM HUNDREDS;" EXECSQLSELECT EXTRACT (HOUR FROM WORKTOTL) INTO :int1 FROM HUNDREDS END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 2; its value is ", int1 if (int1 NOT = 2) then MOVE 0 TO flag END-IF
COMPUTE int1 = -1 DISPLAY"SELECT EXTRACT (MINUTE FROM WORKTOTL)" DISPLAY" INTO :int1 FROM HUNDREDS;" EXECSQLSELECT EXTRACT (MINUTE FROM WORKTOTL) INTO :int1 FROM HUNDREDS END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 should be 11; its value is ", int1 if (int1 NOT = 11) then MOVE 0 TO flag END-IF
*Exact value would have been 2 hours, 11 minutes, *18 seconds. It should get rounded downwards even *if there is rounding/truncation error in previous *calculations.
EXECSQLCOMMIT WORK END-EXEC MOVESQLCODETO SQL-COD ******************** END TEST0694 ******************** ******************** BEGIN TEST0695 ******************* MOVE 1 TO flag
*Note that there are special restrictions on updating through *an ordered cursor, see 13.9 LR.1.a
DISPLAY"DECLARE C13541 CURSOR FOR" DISPLAY" SELECT GRADE FROM HU.STAFF" DISPLAY" FOR READ ONLY;" EXECSQL DECLARE C13541 CURSOR FOR SELECT GRADE FROM HU.STAFF FORREAD ONLY END-EXEC
COMPUTE int1 = -1 DISPLAY"FETCH C13541 INTO :int1;" EXECSQL FETCH C13541 INTO :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 is ", int1
*This may be rejected at compile time. If it is, *save the error message(s) and TEd out this statement.
*Violation of 13.9 SR.2
DISPLAY"UPDATE HU.STAFF" DISPLAY" SET GRADE = 11 WHERE CURRENT OF C13541;" EXECSQL UPDATE HU.STAFF SET GRADE = 11 WHERE CURRENT OF C13541 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 42000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT < 0 OR NORMSQ NOT = "42000") then MOVE 0 TO flag END-IF if (NORMSQ = "42000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
COMPUTE int1 = -1 DISPLAY"FETCH C13541 INTO :int1;" EXECSQL FETCH C13541 INTO :int1 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"int1 is ", int1
*This may be rejected at compile time. If it is, *save the error message(s) and TEd out this statement.
*Violation of 13.6 SR.2
DISPLAY"DELETE FROM HU.STAFF" DISPLAY" WHERE CURRENT OF C13541;" EXECSQLDELETEFROM HU.STAFF WHERE CURRENT OF C13541 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 42000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT < 0 OR NORMSQ NOT = "42000") then MOVE 0 TO flag END-IF if (NORMSQ = "42000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
DISPLAY"DECLARE C13542 CURSOR FOR" DISPLAY" SELECT * FROM HU.STAFF" DISPLAY" FOR UPDATE OF GRADE, CITY;" EXECSQL DECLARE C13542 CURSOR FOR SELECT * FROM HU.STAFF FOR UPDATE OF GRADE, CITY END-EXEC
COMPUTE int1 = -1 DISPLAY"FETCH C13542 INTO :emnum, :ename, :int1, :city;" EXECSQL FETCH C13542 INTO :emnum, :ename, :int1, :city END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"emnum is ", emnum DISPLAY"ename is ", ename DISPLAY"int1 is ", int1 DISPLAY"city is ", city
*This may be rejected at compile time. If it is, *save the error message(s) and TEd out this statement.
*Violation of 13.9 SR.8
DISPLAY"UPDATE HU.STAFF" DISPLAY" SET EMPNUM = 'HAR' WHERE CURRENT OF C13542;" EXECSQL UPDATE HU.STAFF SET EMPNUM = 'HAR'WHERE CURRENT OF C13542 END-EXEC MOVESQLCODETO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 42000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT < 0 OR NORMSQ NOT = "42000") then MOVE 0 TO flag END-IF if (NORMSQ = "42000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF DISPLAY" "
COMPUTE int1 = -1 DISPLAY"FETCH C13542 INTO :emnum, :ename, :int1, :city;" EXECSQL FETCH C13542 INTO :emnum, :ename, :int1, :city END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"emnum is ", emnum DISPLAY"ename is ", ename DISPLAY"int1 is ", int1 DISPLAY"city is ", city
DISPLAY"UPDATE HU.STAFF" DISPLAY" SET GRADE = 11 WHERE CURRENT OF C13542;" EXECSQL UPDATE HU.STAFF SET GRADE = 11 WHERE CURRENT OF C13542 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*This appears to be legal! 13.6
DISPLAY"DELETE FROM HU.STAFF" DISPLAY" WHERE CURRENT OF C13542;" EXECSQLDELETEFROM HU.STAFF WHERE CURRENT OF C13542 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13543 CURSOR FOR" DISPLAY" SELECT * FROM HU.STAFF" DISPLAY" FOR UPDATE;" EXECSQL DECLARE C13543 CURSOR FOR SELECT * FROM HU.STAFF FOR UPDATE END-EXEC
COMPUTE int1 = -1 DISPLAY"FETCH C13543 INTO :emnum, :ename, :int1, :city;" EXECSQL FETCH C13543 INTO :emnum, :ename, :int1, :city END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"emnum is ", emnum DISPLAY"ename is ", ename DISPLAY"int1 is ", int1 DISPLAY"city is ", city
DISPLAY"UPDATE HU.STAFF" DISPLAY" SET EMPNUM = 'HAR' WHERE CURRENT OF C13543;" EXECSQL UPDATE HU.STAFF SET EMPNUM = 'HAR'WHERE CURRENT OF C13543 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DELETE FROM HU.STAFF" DISPLAY" WHERE CURRENT OF C13543;" EXECSQLDELETEFROM HU.STAFF WHERE CURRENT OF C13543 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
EXECSQLCOMMIT WORK END-EXEC MOVESQLCODETO SQL-COD ******************** END TEST0695 ******************** **** 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 = 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 in Prozent
¤ Dauer der Verarbeitung: 0.42 Sekunden
(vorverarbeitet am 2026-04-26)
¤
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.