IBM Support

IZ43786: DB2 MAY ISSUE SQL0901N EXECUTING A QUERY WITH CORRELATED REFERENCES TO A TABLE FROM AN OUTER JOIN

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • An SQL0901N may be issued when executing a query containing a
    LEFT or RIGHT OUTER JOIN (LOJ) if correlation exists to the
    table from the row-preserving (RP) side of the LOJ.
    
    The following conditions must be satisfied for the scenario to
    occur:
    - The RP table has a unique key associated with it
    - 2 or more levels of correlation exist to the RP table
    - All correlated constructs are inner-joined after the LOJ
    (either directly or via transitivity) on the correlated column
    
    An example scenario follows:
    
    -- Table DDL
    CREATE TABLE RP (PK_C CHAR(2) NOT NULL PRIMARY KEY);
    CREATE TABLE NP (J_C CHAR(2));
    
    -- Table Function DDL
    CREATE FUNCTION F1(IN_C CHAR(2))
    RETURNS TABLE   (OUT_C CHAR(2))
    LANGUAGE SQL
    DETERMINISTIC
    NO EXTERNAL ACTION
    BEGIN ATOMIC
     DECLARE DUMMY CHAR(2);--
    SET (DUMMY) = (IN_C);--
    RETURN VALUES(IN_C);--
    END;
    
    CREATE FUNCTION F2(IN_C CHAR(2))
    RETURNS TABLE   (OUT_C CHAR(2))
    LANGUAGE SQL
    DETERMINISTIC
    NO EXTERNAL ACTION
    READS SQL DATA
    RETURN
    SELECT  A.J_C
    FROM  (VALUES(IN_C)) AS A(J_C)
    LEFT OUTER JOIN NP AS B
    ON  B.J_C = A.J_C;
    
    -- Query that will issue the SQL0901N
    SELECT A.PK_C
    FROM   RP AS A,
          TABLE(F1(A.PK_C)) AS B, -- First level of correlation
         TABLE(F2(B.OUT_C)) AS C   -- Second level of correlation
    WHERE A.PK_C = B.OUT_C   -- Explicit inner-join
    AND   B.OUT_C = C.OUT_C   -- Inner-join via transitivity
    ;
    
    -- SQLCODE issued
    SQL0901N  The SQL statement failed because of a non-severe
    system error.
    Subsequent SQL statements can be processed.  (Reason "Bad Plan;
    Unresolved QNC
    found".)  SQLSTATE=58004
    
    This problem will be first fixed in DB2 Version 9.5 Fix Pack 5.
    

Local fix

  • No workaround exists aside from manually rewriting the query in
    question.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * Use a query containing a LEFT or RIGHT OUTER JOIN            *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * An SQL0901N may be issued when executing a query containing  *
    * a                                                            *
    * LEFT or RIGHT OUTER JOIN (LOJ) if correlation exists to the  *
    * table from the row-preserving (RP) side of the LOJ.          *
    *                                                              *
    * The following conditions must be satisfied for the scenario  *
    * to                                                           *
    * occur:                                                       *
    * - The RP table has a unique key associated with it           *
    * - 2 or more levels of correlation exist to the RP table      *
    * - All correlated constructs are inner-joined after the LOJ   *
    * (either directly or via transitivity) on the correlated      *
    * column                                                       *
    *                                                              *
    * An example scenario follows:                                 *
    *                                                              *
    * -- Table DDL                                                 *
    * CREATE TABLE RP (PK_C CHAR(2) NOT NULL PRIMARY KEY);         *
    * CREATE TABLE NP (J_C CHAR(2));                               *
    *                                                              *
    * -- Table Function DDL                                        *
    * CREATE FUNCTION F1(IN_C CHAR(2))                             *
    * RETURNS TABLE   (OUT_C CHAR(2))                              *
    * LANGUAGE SQL                                                 *
    * DETERMINISTIC                                                *
    * NO EXTERNAL ACTION                                           *
    * BEGIN ATOMIC                                                 *
    *  DECLARE DUMMY CHAR(2);--                                    *
    * SET (DUMMY) = (IN_C);--                                      *
    * RETURN VALUES(IN_C);--                                       *
    * END;                                                         *
    *                                                              *
    * CREATE FUNCTION F2(IN_C CHAR(2))                             *
    * RETURNS TABLE   (OUT_C CHAR(2))                              *
    * LANGUAGE SQL                                                 *
    * DETERMINISTIC                                                *
    * NO EXTERNAL ACTION                                           *
    * READS SQL DATA                                               *
    * RETURN                                                       *
    * SELECT  A.J_C                                                *
    * FROM  (VALUES(IN_C)) AS A(J_C)                               *
    * LEFT OUTER JOIN NP AS B                                      *
    * ON  B.J_C = A.J_C;                                           *
    *                                                              *
    * -- Query that will issue the SQL0901N                        *
    * SELECT A.PK_C                                                *
    * FROM   RP AS A,                                              *
    *       TABLE(F1(A.PK_C)) AS B, -- First level of correlation  *
    *      TABLE(F2(B.OUT_C)) AS C   -- Second level of            *
    * correlation                                                  *
    * WHERE A.PK_C = B.OUT_C   -- Explicit inner-join              *
    * AND   B.OUT_C = C.OUT_C   -- Inner-join via transitivity     *
    * ;                                                            *
    *                                                              *
    * -- SQLCODE issued                                            *
    * SQL0901N  The SQL statement failed because of a non-severe   *
    * system error.                                                *
    * Subsequent SQL statements can be processed.  (Reason "Bad    *
    * Plan;                                                        *
    * Unresolved QNC                                               *
    * found".)  SQLSTATE=58004                                     *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to DB2 Version 9.5 Fix Pack 5.                       *
    ****************************************************************
    

Problem conclusion

  • Problem is first fixed in DB2 Version 9.5 Fix Pack 5.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ43786

  • Reported component name

    DB2 UDB ESE AIX

  • Reported component ID

    5765F4100

  • Reported release

    950

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-02-13

  • Closed date

    2010-01-13

  • Last modified date

    2010-01-13

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    IZ43788 IC62688

Fix information

  • Fixed component name

    DB2 UDB ESE AIX

  • Fixed component ID

    5765F4100

Applicable component levels

  • R950 PSN

       UP

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSEPGG","label":"DB2 for Linux, UNIX and Windows"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"950","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
13 January 2010