* Standard COBOL (file "DML135.SCO") calling SQL * procedures in file "DML135.MCO".
**************************************************************** * * COMMENT SECTION * * DATE 1994/8/30 STANDARD 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.SCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE * * This program tests multiple TSQL features together. * * REFERENCES * FIPS PUB 127-2 14.1 Transitional SQL * ANSI SQL-1992 * ****************************************************************
DISPLAY"INSERT INTO ""Works""" DISPLAY" SELECT * FROM Hu.Works;" * EXEC SQL INSERT INTO "Works" * SELECT * FROM Hu.Works; CALL"SUB18"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13511 CURSOR FOR" DISPLAY" SELECT * FROM PTYPES ORDER BY NUM;" * EXEC SQL DECLARE C13511 CURSOR FOR * SELECT * FROM PTYPES ORDER BY NUM END-EXEC
DISPLAY"OPEN C13511;" * EXEC SQL OPEN C13511; CALL"SUB19"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB20"USING SQLCODE SQLSTATE tchar int1 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;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB21"USING SQLCODE SQLSTATE tchar int1 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;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB22"USING SQLCODE SQLSTATE tchar int1 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;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB23"USING SQLCODE SQLSTATE tchar int1 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"CLOSE C13511;" * EXEC SQL CLOSE C13511; CALL"SUB24"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Grouped dynamic cursor over a grouped view
* EXEC SQL DELETE FROM CONCATBUF; CALL"SUB25"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD * EXEC SQL INSERT INTO CONCATBUF VALUES ( * 'SELECT NUM, COUNT(*) FROM "PStaff"' || * ' GROUP BY NUM ORDER BY NUM' * ); CALL"SUB26"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD * EXEC SQL SELECT ZZ INTO :longst FROM CONCATBUF; CALL"SUB27"USING SQLCODE SQLSTATE longst MOVE SQLCODE TO SQL-COD
DISPLAY"longst=""", longst """"
DISPLAY"PREPARE S13512 FROM :longst;" * EXEC SQL PREPARE S13512 FROM :longst; CALL"SUB28"USING SQLCODE SQLSTATE longst MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13512 CURSOR FOR S13512;" * EXEC SQL DECLARE C13512 CURSOR FOR S13512 END-EXEC
DISPLAY"OPEN C13512;" * EXEC SQL OPEN C13512; CALL"SUB29"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB30"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB31"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB32"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB33"USING SQLCODE SQLSTATE int1 int2 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"CLOSE C13512;" * EXEC SQL CLOSE C13512; CALL"SUB34"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Cascaded delete -- ditch all that costly Design work
DISPLAY"DELETE FROM ""Proj"" WHERE PTYPE = 'Design';" * EXEC SQL DELETE FROM "Proj" WHERE PTYPE = 'Design' * ; CALL"SUB35"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"OPEN C13511;" * EXEC SQL OPEN C13511; CALL"SUB19"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
MOVE"xxxxxx"TO tchar COMPUTE int1 = -1 DISPLAY"FETCH C13511 INTO :tchar, :int1;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB37"USING SQLCODE SQLSTATE tchar int1 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;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB38"USING SQLCODE SQLSTATE tchar int1 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;" * EXEC SQL FETCH C13511 INTO :tchar, :int1; CALL"SUB39"USING SQLCODE SQLSTATE tchar int1 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"CLOSE C13511;" * EXEC SQL CLOSE C13511; CALL"SUB40"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"OPEN C13512;" * EXEC SQL OPEN C13512; CALL"SUB29"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13512 INTO :int1, :int2;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB42"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB43"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13512 INTO :int1, :int2; CALL"SUB44"USING SQLCODE SQLSTATE int1 int2 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"CLOSE C13512;" * EXEC SQL CLOSE C13512; CALL"SUB45"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
* EXEC SQL COMMIT WORK; CALL"SUB53"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST0692 ******************** ******************** BEGIN TEST0693 ******************* MOVE 1 TO flag
DISPLAY"DECLARE C13521 CURSOR FOR" DISPLAY" SELECT TABLE_NAME, TABLE_TYPE, COLUMN_NAME," DISPLAY" EXTRACT (HOUR FROM CREATE_TIME)" DISPLAY" FROM TABLESCOLUMNS" DISPLAY" ORDER BY TABLE_NAME, COLUMN_NAME" DISPLAY" FOR READ ONLY;" * EXEC SQL DECLARE C13521 CURSOR FOR * SELECT TABLE_NAME, TABLE_TYPE, COLUMN_NAME, * EXTRACT (HOUR FROM CREATE_TIME) * FROM TABLESCOLUMNS * ORDER BY TABLE_NAME, COLUMN_NAME * FOR READ ONLY END-EXEC
DISPLAY"OPEN C13521;" * EXEC SQL OPEN C13521; CALL"SUB62"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB63"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB64"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB65"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB66"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB67"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB68"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB69"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB70"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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;" * EXEC SQL FETCH C13521 * INTO :tname, :ttype, :cname, :int1:indic1; CALL"SUB71"USING SQLCODE SQLSTATE
tname ttype cname int1 indic1 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);" * EXEC SQL INSERT INTO CREATIONTIMES VALUES * ('FLATER', 'USIG', DEFAULT); CALL"SUB72"USING SQLCODE SQLSTATE 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" "
* EXEC SQL COMMIT WORK; CALL"SUB78"USING SQLCODE SQLSTATE 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));" * EXEC SQL CREATE TABLE WORKS ( * EMPNUM CHAR (3) NOT NULL, * PNUM CHAR (3) NOT NULL, * HOURS DECIMAL (5), * UNIQUE(EMPNUM,PNUM)); CALL"SUB79"USING SQLCODE SQLSTATE 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;" * EXEC SQL 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; CALL"SUB83"USING SQLCODE SQLSTATE 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;" * EXEC SQL CREATE VIEW HUNDREDS (WORKTOTL) AS * SELECT SUM (CAST (HOURS AS INTERVAL DAY TO MINUTE)) / 100 * FROM PROJ_HOURS; CALL"SUB91"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS" DISPLAY" SELECT * FROM HU.WORKS;" * EXEC SQL INSERT INTO WORKS * SELECT * FROM HU.WORKS; CALL"SUB93"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS VALUES" DISPLAY" ('EX', 'P1', 50);" * EXEC SQL INSERT INTO WORKS VALUES * ('EX', 'P1', 50); CALL"SUB94"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO WORKS VALUES" DISPLAY" ('EX', 'P3', 25);" * EXEC SQL INSERT INTO WORKS VALUES * ('EX', 'P3', 25); CALL"SUB95"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO RUN_TIMES VALUES" DISPLAY" (0, 'DMP', 1.22);" * EXEC SQL INSERT INTO RUN_TIMES VALUES * (0, 'DMP', 1.22); CALL"SUB96"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO RUN_TIMES VALUES" DISPLAY" (1, 'DMP', .49);" * EXEC SQL INSERT INTO RUN_TIMES VALUES * (1, 'DMP', .49); CALL"SUB97"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO RUN_TIMES VALUES" DISPLAY" (2, 'CHK', 5.2);" * EXEC SQL INSERT INTO RUN_TIMES VALUES * (2, 'CHK', 5.2); CALL"SUB98"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO RUN_TIMES VALUES" DISPLAY" (3, 'CHK', 4.04);" * EXEC SQL INSERT INTO RUN_TIMES VALUES * (3, 'CHK', 4.04); CALL"SUB99"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"INSERT INTO RUN_TIMES VALUES" DISPLAY" (4, 'CHK', 23.74);" * EXEC SQL INSERT INTO RUN_TIMES VALUES * (4, 'CHK', 23.74); CALL"SUB100"USING SQLCODE SQLSTATE 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;" * EXEC SQL SELECT COUNT(*) 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 * ; CALL"SUB101"USING SQLCODE SQLSTATE int1 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;" * EXEC SQL SELECT COUNT(*) 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; CALL"SUB102"USING SQLCODE SQLSTATE int1 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;" * EXEC SQL DECLARE C13531 CURSOR FOR * SELECT EXTRACT (HOUR FROM HOURS), * EXTRACT (MINUTE FROM HOURS) * FROM PROJ_HOURS ORDER BY PNUM END-EXEC
DISPLAY"OPEN C13531;" * EXEC SQL OPEN C13531; CALL"SUB103"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE int1 = -1 COMPUTE int2 = -1 DISPLAY"FETCH C13531 INTO :int1, :int2;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB104"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB105"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB106"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB107"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB108"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB109"USING SQLCODE SQLSTATE int1 int2 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;" * EXEC SQL FETCH C13531 INTO :int1, :int2; CALL"SUB110"USING SQLCODE SQLSTATE int1 int2 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"CLOSE C13531;" * EXEC SQL CLOSE C13531; CALL"SUB111"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE C13532 CURSOR FOR" DISPLAY" SELECT EXTRACT (SECOND FROM RUN_SECONDS)" DISPLAY" FROM TYPE_TIMES ORDER BY JOB_TYPE;" * EXEC SQL DECLARE C13532 CURSOR FOR * SELECT EXTRACT (SECOND FROM RUN_SECONDS) * FROM TYPE_TIMES ORDER BY JOB_TYPE END-EXEC
DISPLAY"OPEN C13532;" * EXEC SQL OPEN C13532; CALL"SUB112"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
COMPUTE flt1 = -1.0 DISPLAY"FETCH C13532 INTO :flt1;" * EXEC SQL FETCH C13532 INTO :flt1; CALL"SUB113"USING SQLCODE SQLSTATE flt1 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;" * EXEC SQL FETCH C13532 INTO :flt1; CALL"SUB114"USING SQLCODE SQLSTATE flt1 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;" * EXEC SQL FETCH C13532 INTO :flt1; CALL"SUB115"USING SQLCODE SQLSTATE flt1 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"CLOSE C13532;" * EXEC SQL CLOSE C13532; CALL"SUB116"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY" "
*Test interval divide
COMPUTE int1 = -1 DISPLAY"SELECT EXTRACT (DAY FROM WORKTOTL)" DISPLAY" INTO :int1 FROM HUNDREDS;" * EXEC SQL SELECT EXTRACT (DAY FROM WORKTOTL) * INTO :int1 FROM HUNDREDS; CALL"SUB117"USING SQLCODE SQLSTATE int1 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;" * EXEC SQL SELECT EXTRACT (HOUR FROM WORKTOTL) * INTO :int1 FROM HUNDREDS; CALL"SUB118"USING SQLCODE SQLSTATE int1 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;" * EXEC SQL SELECT EXTRACT (MINUTE FROM WORKTOTL) * INTO :int1 FROM HUNDREDS; CALL"SUB119"USING SQLCODE SQLSTATE int1 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.
* EXEC SQL COMMIT WORK; CALL"SUB127"USING SQLCODE SQLSTATE MOVE SQLCODE TO SQL-COD ******************** END TEST0694 ******************** ******************** BEGIN TEST0695 ******************* MOVE 1 TO flag
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.