*Copyright 1995 National Computing Centre Limited *and Computer Logic R&D S.A *on behalf of the CTS5 SQL2 Project. *All rights reserved. *The CTS5 SQL2 Project is sponsored by the European Community. * *The National Computing Centre Limited and Computer Logic R&D *have given permission to NIST to distribute this program *over the World Wide Web in order to promote SQL standards. *DISCLAIMER: *This program was reviewed by employees of NIST for *conformance to the SQL standards. *NIST assumes no responsibility for any party's use of *this program.
**************************************************************** * * COMMENT SECTION * * SQL VALIDATION TEST SUITE V6.0 * * XTS733.PCO * WRITTEN BY: Manolis Megaloikonomou * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * FULL OUTER JOIN <table ref> ON <search condition> -- static. * * REFERENCES * 7.10 -- <query expression> * 7.10 LR.2c -- Raised. Entry SQL restriction which * prohibited the use of a <joined table> * within a <query expression>. * 6.3 -- <Table reference>. * 6.3 LR.2a -- Raised. Entry SQL restriction which * prohibited the use of a <joined table> * in a <table reference>. * 7.5 -- <joined table>. * 7.5 GR.1.c * 7.5 GR.5.d * 7.5 GR.6.b * 7.5 LR.2a -- Raised. Entry SQL restriction which * prohibited the use of a <joined table> * in a <table reference>. * F#4 -- Joined table. * F#24 -- Keyword relaxations. * F#40 -- Full outer join. * * DATE LAST ALTERED 18/12/95 CTS5 Hand-over Test * * Cleanups and fixes by V. Kogakis 06/12/95 * * QA STATUS : * * Revised by DWF 1996-02-06 * Removed status checks after cursor definition * Fixed expected results & allowed nulls to be sorted first * Fixed null value no indicator parms * Check indicators instead of expecting data not to change ****************************************************************
MOVE"CTS1 "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECT USER INTO :uidx FROM CTS1.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 MOVE0TO errcnt
DISPLAY"SQL Test Suite, V6.0, Embedded COBOL, xts733.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 TEST7033 *******************
MOVE1TO flag DISPLAY" TEST7033 " DISPLAY" FULL OUTER JOIN <table ref> ON <search
- " condition> --static." DISPLAY"References:" DISPLAY" 7.10 -- <query expression>" DISPLAY" 7.10 LR.2c -- Raised. Entry SQL restriction
- " which" DISPLAY" prohibited the use of a <joined
- " table>" DISPLAY" within a <query expression>." DISPLAY" 6.3 -- <Table reference>." DISPLAY" 6.3 LR.2a -- Raised. Entry SQL restriction
- " which" DISPLAY" prohibited the use of a <joined
- " table>" DISPLAY" in a <table reference>." DISPLAY" 7.5 -- <joined table>." DISPLAY" 7.5 GR.1.c" DISPLAY" 7.5 GR.5.d" DISPLAY" 7.5 GR.6.b" DISPLAY" 7.5 LR.2a -- Raised. Entry SQL restriction
- " which" DISPLAY" prohibited the use of a <joined
- " table>" DISPLAY" in a <table reference>." DISPLAY" F#4 -- Joined table." DISPLAY" F#24 -- Keyword relaxations." DISPLAY" F#40 -- Full outer join." DISPLAY" - - - - - - - - - - - - - - - - - - -"
*Ensure that the tables TEST6840A, TEST6840B, TEST6840C are empt EXECSQLDELETEFROM TEST6840A END-EXEC MOVESQLCODETO SQL-COD EXECSQLDELETEFROM TEST6840B END-EXEC MOVESQLCODETO SQL-COD EXECSQLDELETEFROM TEST6840C END-EXEC MOVESQLCODETO SQL-COD
*Insert two rows of non null values into TEST6840A DISPLAY"INSERT INTO TEST6840A VALUES (1,'A');" EXECSQLINSERTINTO TEST6840A VALUES (1,'A') END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" " DISPLAY"INSERT INTO TEST6840A VALUES (2,'B');" EXECSQLINSERTINTO TEST6840A VALUES (2,'B') END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*Insert two rows of non null values into TEST6840B DISPLAY"INSERT INTO TEST6840B VALUES (2,'C');" EXECSQLINSERTINTO TEST6840B VALUES (2,'C') END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" " DISPLAY"INSERT INTO TEST6840B VALUES (3,'A');" EXECSQLINSERTINTO TEST6840B VALUES (3,'A') END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
DISPLAY"DECLARE a CURSOR" DISPLAY"FOR SELECT * FROM TEST6840A FULL OUTER JOIN
- " TEST6840B" DISPLAY"ON NUM_A = NUM_B ORDER BY NUM_A;" EXECSQL DECLARE a CURSOR FORSELECT * FROM TEST6840A FULL OUTER JOIN TEST6840B ON NUM_A = NUM_B ORDERBY NUM_A END-EXEC
*Result should be: *NUM_A CH_A NUM_B CH_B *----- ---- ----- ---- * 1 A NULL NULL * 2 B 2 C *NULL NULL 3 A *Except that the last row might actually be the first: *13.1 GR.3.b: Whether nulls sort above or below non-nulls is *implementation-defined!
*flag2 will be set if the null row is first. MOVE0TO flag2
DISPLAY"FETCH a INTO :xtnum1:indic1, :xtchar1:indic2," DISPLAY" :xtnum2:indic3, :xtchar2:indic4;" EXECSQL FETCH a INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK if (indic1 = -1AND flag2 = 0) then DISPLAY"Sorting order is nulls-first." MOVE1TO flag2 GOTO P100 END-IF if (indic1 NOT = -1AND flag2 = 0) then DISPLAY"Sorting order is nulls-last." END-IF DISPLAY"xtnum1 should be 1; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 if (xtnum1 NOT = 1OR xtchar1 NOT = "A") then MOVE0TO flag END-IF if (indic3 NOT = -1OR indic4 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"FETCH a INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2;" EXECSQL FETCH a INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be B; its value is ", xtchar1 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be C; its value is ", xtchar2 if ( xtnum1 NOT = 2OR xtchar1 NOT = "B") then MOVE0TO flag END-IF if ( xtnum2 NOT = 2OR xtchar2 NOT = "C") then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"FETCH a INTO :xtnum1:indic1, :xtchar1:indic2," DISPLAY" :xtnum2:indic3, :xtchar2:indic4;" EXECSQL FETCH a INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK
.
P100. DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum2 should be 3; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if ( xtnum2 NOT = 3OR xtchar2 NOT = "A") then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"DECLARE b CURSOR" DISPLAY"FOR SELECT * FROM TEST6840A FULL JOIN TEST6840B" DISPLAY"ON CH_A = CH_B ORDER BY NUM_A;" EXECSQL DECLARE b CURSOR FORSELECT * FROM TEST6840A FULL JOIN TEST6840B ON CH_A = CH_B ORDERBY NUM_A END-EXEC
*Result should be: *NUM_A CH_A NUM_B CH_B *----- ---- ----- ---- * 1 A 3 A * 2 B NULL NULL * NULL NULL 2 C *Again, the sorting order is uncertain because of the null.
DISPLAY"FETCH b INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2;" EXECSQL FETCH b INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 1; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"xtnum2 should be 3; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 if ( xtnum1 NOT = 1OR xtchar1 NOT = "A" ) then MOVE0TO flag END-IF if ( xtnum2 NOT = 3OR xtchar2 NOT = "A" ) then MOVE0TO flag END-IF DISPLAY" "
EXECSQL FETCH b INTO :xtnum1, :xtchar1,
:xtnum2:indic1, :xtchar2:indic2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be B; its value is ", xtchar1 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 if ( xtnum1 NOT = 2OR xtchar1 NOT = "B" ) then MOVE0TO flag END-IF if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"FETCH b INTO :xtnum1:indic1, :xtchar1:indic2," DISPLAY" :xtnum2, :xtchar2;" EXECSQL FETCH b INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2, :xtchar2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be C; its value is ", xtchar2 if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if ( xtnum2 NOT = 2OR xtchar2 NOT = "C" ) then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"INSERT INTO TEST6840C" DISPLAY"TEST6840A FULL OUTER JOIN TEST6840B ON NUM_A = 2;" EXECSQLINSERTINTO TEST6840C
TEST6840A FULL OUTER JOIN TEST6840B ON NUM_A = 2END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY" "
*TEST6840C is now: *NUM_C1 CH_C1 NUM_C2 CH_C2 *------ ----- ------ ----- * 2 B 2 C * 2 B 3 A * 1 A NULL NULL
MOVE99TO coun DISPLAY"SELECT COUNT(*) INTO :coun FROM TEST6840C;" EXECSQLSELECTCOUNT(*) INTO :coun FROM TEST6840C END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"coun should be 3; its value is ", coun if (coun NOT = 3) then MOVE0TO flag END-IF DISPLAY" "
MOVE99TO coun DISPLAY"SELECT COUNT(*) INTO :coun FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 1 AND CH_C1 = 'A' " DISPLAY"AND NUM_C2 IS NULL AND CH_C2 IS NULL;" EXECSQLSELECTCOUNT(*) INTO :coun FROM TEST6840C WHERE NUM_C1 = 1AND CH_C1 = 'A'AND NUM_C2 ISNULLAND
CH_C2 ISNULLEND-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"coun should be 1; its value is ", coun if (coun NOT = 1) then MOVE0TO flag END-IF DISPLAY" "
MOVE99TO coun DISPLAY"SELECT COUNT(*) INTO :coun FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 2 AND CH_C1 = 'B' AND NUM_C2 = 2
- " AND CH_C2 = 'C';" EXECSQLSELECTCOUNT(*) INTO :coun FROM TEST6840C WHERE NUM_C1 = 2AND CH_C1 = 'B'AND NUM_C2 = 2AND CH_C2
= 'C'END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"coun should be 1; its value is ", coun if (coun NOT = 1) then MOVE0TO flag END-IF DISPLAY" "
MOVE99TO coun DISPLAY"SELECT COUNT(*) INTO :coun FROM TEST6840C" DISPLAY"WHERE NUM_C1 = 2 AND CH_C1 = 'B' AND NUM_C2 = 3
- " AND CH_C2 = 'A';" EXECSQLSELECTCOUNT(*) INTO :coun FROM TEST6840C WHERE NUM_C1 = 2AND CH_C1 = 'B'AND NUM_C2 = 3AND
CH_C2 = 'A'END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"coun should be 1; its value is ", coun if (coun NOT = 1) then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"DECLARE c CURSOR FOR SELECT * FROM" DISPLAY"(TEST6840B FULL JOIN TEST6840A AS CN1 ON
- " TEST6840B.CH_B = CN1.CH_A)" DISPLAY"FULL JOIN TEST6840A AS CN2 ON TEST6840B.NUM_B =
- " CN2.NUM_A" DISPLAY"ORDER BY TEST6840B.NUM_B, CN1.NUM_A;" EXECSQL DECLARE c CURSOR FORSELECT * FROM
(TEST6840B FULL JOIN TEST6840A AS CN1 ON TEST6840B.CH_B =
CN1.CH_A)
FULL JOIN TEST6840A AS CN2 ON TEST6840B.NUM_B = CN2.NUM_A ORDERBY TEST6840B.NUM_B, CN1.NUM_A END-EXEC
*TEST6840B is *NUM_B CH_B *----- ---- * 2 C * 3 A
*TEST6840A is *NUM_A CH_A *----- ---- * 1 A * 2 B
*TEST6840B FULL JOIN TEST6840A AS CN1 ON TEST6840B.CH_B = CN1.CH *NUM_B CH_B NUM_A CH_A *----- ---- ----- ---- * 3 A 1 A * 2 C NULL NULL * NULL NULL 2 B
*... FULL JOIN TEST6840A AS CN2 ON TEST6840B.NUM_B = CN2.NUM_A *Result should be (nulls last): *NUM_B CH_B CN1.NUM_A CN1.CH_A CN2.NUM_A CN2.CH_A *----- ---- --------- -------- --------- -------- * 2 C NULL NULL 2 B * 3 A 1 A NULL NULL *NULL NULL 2 B NULL NULL *NULL NULL NULL NULL 1 A *or (nulls first): *NUM_B CH_B CN1.NUM_A CN1.CH_A CN2.NUM_A CN2.CH_A *----- ---- --------- -------- --------- -------- *NULL NULL NULL NULL 1 A *NULL NULL 2 B NULL NULL * 2 C NULL NULL 2 B * 3 A 1 A NULL NULL
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 DISPLAY"FETCH c INTO :xtnum1, :xtchar1, :xtnum2:indic1," DISPLAY":xtchar2:indic2, :xtnum3, :xtchar3;" EXECSQL FETCH c INTO :xtnum1, :xtchar1, :xtnum2:indic1,
:xtchar2:indic2, :xtnum3, :xtchar3 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be C; its value is ", xtchar1 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum3 should be 2; its value is ", xtnum3 DISPLAY"xtchar3 should be B; its value is ", xtchar3 if (xtnum1 NOT = 2OR xtchar1 NOT = "C"OR
indic1 NOT = -1) then MOVE0TO flag END-IF if (indic2 NOT = -1OR xtnum3 NOT = 2OR xtchar3 NOT
= "B") then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 DISPLAY"FETCH c INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3:indic1, :xtchar3:indic2;" EXECSQL FETCH c INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3:indic1, :xtchar3:indic2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 3; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"xtnum2 should be 1; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 if ( xtnum1 NOT = 3OR xtchar1 NOT = "A"OR
xtnum2 NOT = 1) then MOVE0TO flag END-IF if (xtchar2 NOT = "A"OR indic1 NOT = -1OR
indic2 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 EXECSQL FETCH c INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2, :xtchar2, :xtnum3:indic3, :xtchar3:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be B; its value is ", xtchar2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 if (indic1 NOT = -1OR indic2 NOT = -1OR xtnum2 NOT = 2) then MOVE0TO flag END-IF if (xtchar2 NOT = "B"OR indic3 NOT = -1OR
indic4 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH c INTO :xtnum1:indic1, :xtchar1:indic2," DISPLAY":xtnum2:indic3, :xtchar2:indic4, :xtnum3,
- " :xtchar3;" EXECSQL FETCH c INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4, :xtnum3, :xtchar3 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 DISPLAY"xtnum3 should be 1; its value is ", xtnum3 DISPLAY"xtchar3 should be A; its value is ", xtchar3 if (indic1 NOT = -1OR indic2 NOT = -1OR indic3 NOT = -1) then MOVE0TO flag END-IF if (indic4 NOT = -1OR xtnum3 NOT = 1OR xtchar3 NOT
= "A") then MOVE0TO flag END-IF DISPLAY" "
GOTO P107
*nulls-first branch
.
P106. MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH c INTO :xtnum1:indic1, :xtchar1:indic2," DISPLAY":xtnum2:indic3, :xtchar2:indic4, :xtnum3,
- " :xtchar3;" EXECSQL FETCH c INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4, :xtnum3, :xtchar3 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 DISPLAY"xtnum3 should be 1; its value is ", xtnum3 DISPLAY"xtchar3 should be A; its value is ", xtchar3 if (indic1 NOT = -1OR indic2 NOT = -1OR indic3 NOT = -1) then MOVE0TO flag END-IF if (indic4 NOT = -1OR xtnum3 NOT = 1OR xtchar3 NOT
= "A") then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 EXECSQL FETCH c INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2, :xtchar2, :xtnum3:indic3, :xtchar3:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be B; its value is ", xtchar2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 if (indic1 NOT = -1OR indic2 NOT = -1OR xtnum2 NOT = 2) then MOVE0TO flag END-IF if (xtchar2 NOT = "B"OR indic3 NOT = -1OR
indic4 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 DISPLAY"FETCH c INTO :xtnum1, :xtchar1, :xtnum2:indic1," DISPLAY":xtchar2:indic2, :xtnum3, :xtchar3;" EXECSQL FETCH c INTO :xtnum1, :xtchar1, :xtnum2:indic1,
:xtchar2:indic2, :xtnum3, :xtchar3 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be C; its value is ", xtchar1 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"xtnum3 should be 2; its value is ", xtnum3 DISPLAY"xtchar3 should be B; its value is ", xtchar3 if (xtnum1 NOT = 2OR xtchar1 NOT = "C"OR
indic1 NOT = -1) then MOVE0TO flag END-IF if (indic2 NOT = -1OR xtnum3 NOT = 2OR xtchar3 NOT
= "B") then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE99TO indic1 MOVE99TO indic2 DISPLAY"FETCH c INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3:indic1, :xtchar3:indic2;" EXECSQL FETCH c INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3:indic1, :xtchar3:indic2 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 3; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"xtnum2 should be 1; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 if ( xtnum1 NOT = 3OR xtchar1 NOT = "A"OR
xtnum2 NOT = 1) then MOVE0TO flag END-IF if (xtchar2 NOT = "A"OR indic1 NOT = -1OR
indic2 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
DISPLAY"DECLARE d CURSOR FOR SELECT * FROM" DISPLAY"(TEST6840A AS CN3 FULL OUTER JOIN TEST6840A AS
- " CN4" DISPLAY" ON CN3.NUM_A = CN4.NUM_A) FULL OUTER JOIN" DISPLAY"(TEST6840B AS CN5 FULL OUTER JOIN TEST6840B AS
- " CN6" DISPLAY" ON CN5.CH_B = CN6.CH_B) ON CN3.NUM_A = CN5.NUM_B" DISPLAY"ORDER BY CN3.NUM_A;" EXECSQL DECLARE d CURSOR FORSELECT * FROM
(TEST6840A AS CN3 FULL OUTER JOIN TEST6840A AS CN4 ON CN3.NUM_A = CN4.NUM_A)
FULL OUTER JOIN
(TEST6840B AS CN5 FULL OUTER JOIN TEST6840B AS CN6 ON CN5.CH_B = CN6.CH_B) ON CN3.NUM_A = CN5.NUM_B ORDERBY CN3.NUM_A END-EXEC
*TEST6840A is *NUM_A CH_A *----- ---- * 1 A * 2 B
*TEST6840B is *NUM_B CH_B *----- ---- * 2 C * 3 A
*TEST6840A AS CN3 FULL OUTER JOIN TEST6840A AS CN4 * ON CN3.NUM_A = CN4.NUM_A *CN3.NUM_A CN3.CH_A CN4.NUM_A CN4.CH_A *--------- -------- --------- -------- * 1 A 1 A * 2 B 2 B
*TEST6840B AS CN5 FULL OUTER JOIN TEST6840B AS CN6 * ON CN5.CH_B = CN6.CH_B *CN5.NUM_B CN5.CH_B CN6.NUM_B CN6.CH_B *--------- -------- --------- -------- * 2 C 2 C * 3 A 3 A
*... OUTER JOIN ... ON CN3.NUM_A = CN5.NUM_B ORDER BY CN3.NUM_A *Result should be *CN3.NUM_ACN3.CH_ACN4.NUM_ACN4.CH_ACN5.NUM_BCN5.CH_BCN6.NUM_BCN6 *--------------------------------------------------------------- * 1 A 1 A NULL NULL NULL * 2 B 2 B 2 C 2 * NULL NULL NULL NULL 3 A 3 *Or last row can be first for nulls-first sorting.
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3:indic1, :xtchar3:indic2, :xtnum4:indic3,
- " :xtchar4:indic4;" EXECSQL FETCH d INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3:indic1, :xtchar3:indic2, :xtnum4:indic3,
:xtchar4:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 1; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"xtnum2 should be 1; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 if ( xtnum1 NOT = 1OR xtchar1 NOT = "A") then MOVE0TO flag END-IF if ( xtnum2 NOT = 1OR xtchar2 NOT = "A") then MOVE0TO flag END-IF if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if (indic3 NOT = -1OR indic4 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3, :xtchar3, :xtnum4, :xtchar4;" EXECSQL FETCH d INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3, :xtchar3, :xtnum4, :xtchar4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be B; its value is ", xtchar1 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be B; its value is ", xtchar2 DISPLAY"xtnum3 should be 2; its value is ", xtnum3 DISPLAY"xtchar3 should be C; its value is ", xtchar3 DISPLAY"xtnum4 should be 2; its value is ", xtnum4 DISPLAY"xtchar4 should be C; its value is ", xtchar4 if ( xtnum1 NOT = 2OR xtchar1 NOT = "B") then MOVE0TO flag END-IF if ( xtnum2 NOT = 2OR xtchar2 NOT = "B") then MOVE0TO flag END-IF if ( xtnum3 NOT = 2OR xtchar3 NOT = "C") then MOVE0TO flag END-IF if ( xtnum4 NOT = 2OR xtchar4 NOT = "C") then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3, :xtchar3, :xtnum4, :xtchar4;" EXECSQL FETCH d INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4,
:xtnum3, :xtchar3, :xtnum4, :xtchar4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 DISPLAY"xtnum3 should be 3; its value is ", xtnum3 DISPLAY"xtchar3 should be A; its value is ", xtchar3 DISPLAY"xtnum4 should be 3; its value is ", xtnum4 DISPLAY"xtchar4 should be A; its value is ", xtchar4 if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if (indic3 NOT = -1OR indic4 NOT = -1) then MOVE0TO flag END-IF if ( xtnum3 NOT = 3OR xtchar3 NOT = "A") then MOVE0TO flag END-IF if ( xtnum4 NOT = 3OR xtchar4 NOT = "A") then MOVE0TO flag END-IF DISPLAY" "
GOTO P108
.
P109.
*nulls-first branch MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3, :xtchar3, :xtnum4, :xtchar4;" EXECSQL FETCH d INTO :xtnum1:indic1, :xtchar1:indic2,
:xtnum2:indic3, :xtchar2:indic4,
:xtnum3, :xtchar3, :xtnum4, :xtchar4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 DISPLAY"xtnum3 should be 3; its value is ", xtnum3 DISPLAY"xtchar3 should be A; its value is ", xtchar3 DISPLAY"xtnum4 should be 3; its value is ", xtnum4 DISPLAY"xtchar4 should be A; its value is ", xtchar4 if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if (indic3 NOT = -1OR indic4 NOT = -1) then MOVE0TO flag END-IF if ( xtnum3 NOT = 3OR xtchar3 NOT = "A") then MOVE0TO flag END-IF if ( xtnum4 NOT = 3OR xtchar4 NOT = "A") then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 MOVE99TO indic1 MOVE99TO indic2 MOVE99TO indic3 MOVE99TO indic4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3:indic1, :xtchar3:indic2, :xtnum4:indic3,
- " :xtchar4:indic4;" EXECSQL FETCH d INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3:indic1, :xtchar3:indic2, :xtnum4:indic3,
:xtchar4:indic4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 1; its value is ", xtnum1 DISPLAY"xtchar1 should be A; its value is ", xtchar1 DISPLAY"xtnum2 should be 1; its value is ", xtnum2 DISPLAY"xtchar2 should be A; its value is ", xtchar2 DISPLAY"indic1 should be -1; its value is ", indic1 DISPLAY"indic2 should be -1; its value is ", indic2 DISPLAY"indic3 should be -1; its value is ", indic3 DISPLAY"indic4 should be -1; its value is ", indic4 if ( xtnum1 NOT = 1OR xtchar1 NOT = "A") then MOVE0TO flag END-IF if ( xtnum2 NOT = 1OR xtchar2 NOT = "A") then MOVE0TO flag END-IF if (indic1 NOT = -1OR indic2 NOT = -1) then MOVE0TO flag END-IF if (indic3 NOT = -1OR indic4 NOT = -1) then MOVE0TO flag END-IF DISPLAY" "
MOVE999TO xtnum1 MOVE999TO xtnum2 MOVE999TO xtnum3 MOVE999TO xtnum4 MOVE"xxxxxxxxxx"TO xtchar1 MOVE"xxxxxxxxxx"TO xtchar2 MOVE"xxxxxxxxxx"TO xtchar3 MOVE"xxxxxxxxxx"TO xtchar4 DISPLAY"FETCH d INTO :xtnum1, :xtchar1, :xtnum2,
- " :xtchar2," DISPLAY":xtnum3, :xtchar3, :xtnum4, :xtchar4;" EXECSQL FETCH d INTO :xtnum1, :xtchar1, :xtnum2, :xtchar2,
:xtnum3, :xtchar3, :xtnum4, :xtchar4 END-EXEC MOVESQLCODETO SQL-COD PERFORM CHCKOK DISPLAY"xtnum1 should be 2; its value is ", xtnum1 DISPLAY"xtchar1 should be B; its value is ", xtchar1 DISPLAY"xtnum2 should be 2; its value is ", xtnum2 DISPLAY"xtchar2 should be B; its value is ", xtchar2 DISPLAY"xtnum3 should be 2; its value is ", xtnum3 DISPLAY"xtchar3 should be C; its value is ", xtchar3 DISPLAY"xtnum4 should be 2; its value is ", xtnum4 DISPLAY"xtchar4 should be C; its value is ", xtchar4 if ( xtnum1 NOT = 2OR xtchar1 NOT = "B") then MOVE0TO flag END-IF if ( xtnum2 NOT = 2OR xtchar2 NOT = "B") then MOVE0TO flag END-IF if ( xtnum3 NOT = 2OR xtchar3 NOT = "C") then MOVE0TO flag END-IF if ( xtnum4 NOT = 2OR xtchar4 NOT = "C") then MOVE0TO flag END-IF DISPLAY" "
EXECSQLCOMMIT WORK END-EXEC MOVESQLCODETO SQL-COD ******************** END TEST7033 ********************
END-IF **** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0 STOPRUN.
* **** Procedures for PERFORM statements
*Test SQLCODE and SQLSTATE for normal completion.
CHCKOK. DISPLAY"SQLCODE should be 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 00000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODENOT = 0OR NORMSQ NOT = "00000") then MOVE0TO flag END-IF if (NORMSQ = "00000"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
MOVE3TO norm1 *subclass begins in position 3 of char array NORMSQ *valid subclass begins with 5-9, I-Z, end of ALPNUM table PERFORMVARYING norm2 FROM14BY1UNTIL 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
MOVE4TO norm1 *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORMVARYING norm2 FROM1BY1UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
MOVE5TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING norm2 FROM1BY1UNTIL 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
.
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.