**************************************************************** * * 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 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, 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"CREATE VIEW PTYPES AS" DISPLAY" SELECT * FROM ""PTypes""" DISPLAY" WHERE NUM > 1;" EXECSQL CREATE VIEW PTYPES AS SELECT * FROM"PTypes"
WHERE NUM > 1 END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO ""Works""" DISPLAY" SELECT * FROM Hu.Works;" EXECSQLINSERTINTO"Works" SELECT * FROM Hu.Works END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO SQL-COD EXECSQLINSERTINTO CONCATBUF VALUES ( 'SELECT NUM, COUNT(*) FROM "PStaff"' || ' GROUP BY NUM ORDER BY NUM'
) END-EXEC MOVE SQLCODE TO SQL-COD EXECSQLSELECT ZZ INTO :longst FROM CONCATBUF END-EXEC MOVE SQLCODE TO SQL-COD
DISPLAY"longst=""", longst """"
DISPLAY"PREPARE S13512 FROM :longst;" EXECSQL PREPARE S13512 FROM :longst END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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" "
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO 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 (SQLCODE NOT < 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" "
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO 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 TABLE WORKS (" DISPLAY" EMPNUM CHAR (3) NOT NULL," DISPLAY" PNUM CHAR (3) NOT NULL," DISPLAY" HOURS DECIMAL (5)," DISPLAY" UNIQUE(EMPNUM,PNUM));" EXECSQL CREATE TABLE WORKS (
EMPNUM CHAR (3) NOTNULL,
PNUM CHAR (3) NOTNULL,
HOURS DECIMAL (5),
UNIQUE(EMPNUM,PNUM)) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
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 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE TABLE RUN_TIMES (" DISPLAY" JOB_ID INT NOT NULL UNIQUE," DISPLAY" JOB_TYPE CHAR (3) NOT NULL," DISPLAY" RUN_SECONDS REAL);" EXECSQL CREATE TABLE RUN_TIMES (
JOB_ID INT NOTNULL UNIQUE,
JOB_TYPE CHAR (3) NOTNULL,
RUN_SECONDS REAL) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE VIEW TYPE_TIMES (JOB_TYPE, RUN_SECONDS) AS" DISPLAY" SELECT JOB_TYPE," DISPLAY" AVG (RUN_SECONDS) * INTERVAL '01.000000' SECOND" DISPLAY" FROM RUN_TIMES GROUP BY JOB_TYPE;" EXECSQL CREATE VIEW TYPE_TIMES (JOB_TYPE, RUN_SECONDS) AS SELECT JOB_TYPE,
AVG (RUN_SECONDS) * INTERVAL '01.000000' SECOND FROM RUN_TIMES GROUP BY JOB_TYPE END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE VIEW TYPE_TIMES2 (JOB_TYPE, RUN_SECONDS)
- " AS" DISPLAY" SELECT JOB_TYPE," DISPLAY" CAST (CAST (AVG (RUN_SECONDS) AS NUMERIC (8,
- " 6))" DISPLAY" AS INTERVAL SECOND)" DISPLAY" FROM RUN_TIMES GROUP BY JOB_TYPE;" EXECSQL CREATE VIEW TYPE_TIMES2 (JOB_TYPE, RUN_SECONDS) AS SELECT JOB_TYPE,
CAST (CAST (AVG (RUN_SECONDS) AS NUMERIC (8, 6))
AS INTERVAL SECOND) FROM RUN_TIMES GROUP BY JOB_TYPE END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"CREATE VIEW HUNDREDS (WORKTOTL) AS" DISPLAY" SELECT SUM (CAST (HOURS AS INTERVAL DAY TO
- " MINUTE)) / 100" DISPLAY" FROM PROJ_HOURS;" EXECSQL CREATE VIEW HUNDREDS (WORKTOTL) AS SELECTSUM (CAST (HOURS AS INTERVAL DAYTO MINUTE)) / 100 FROM PROJ_HOURS END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS" DISPLAY" SELECT * FROM HU.WORKS;" EXECSQLINSERTINTO WORKS SELECT * FROM HU.WORKS END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS VALUES" DISPLAY" ('EX', 'P1', 50);" EXECSQLINSERTINTO WORKS VALUES
('EX', 'P1', 50) END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS VALUES" DISPLAY" ('EX', 'P3', 25);" EXECSQLINSERTINTO WORKS VALUES
('EX', 'P3', 25) END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT = 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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.
DISPLAY"ROLLBACK WORK;" EXECSQL ROLLBACK WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DROP TABLE WORKS CASCADE;" EXECSQL DROP TABLE WORKS CASCADE END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DROP TABLE RUN_TIMES CASCADE;" EXECSQL DROP TABLE RUN_TIMES CASCADE END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"COMMIT WORK;" EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
if ( flag = 1 ) then DISPLAY" *** pass *** " EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0694','pass','PCO') END-EXEC MOVE SQLCODE TO SQL-COD else DISPLAY" dml135.pco *** fail *** " EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0694','fail','PCO') END-EXEC MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT < 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO 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 (SQLCODE NOT < 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 MOVE SQLCODE TO 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 MOVE SQLCODE TO SQL-COD DISPLAY"SQLCODE should be < 0; its value is ", SQL-COD
--> --------------------
--> maximum size reached
--> --------------------
¤ 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.0.49Bemerkung:
¤
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.