IBM Support

IC87978: QUERY WITH OLAP FUNCTION AND SET OPERATIONS MIGHT PRODUCE SQL0901N

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Under certain scenarios, DB2 might return a SQL0901N error
    message.
    
    SQL0901N  The SQL statement or command failed because of a
    database system
    error. (Reason "Bad Opcode 0, ref_arity 2, sqlnq_pid ID 943
    (SYSIBM.SCALAG)".)
    SQLSTATE=58004
    
    Conditions required to hit this problem are as follows:
    1. The query has one or more OLAP functions in the select list.
    eg. count(c1) over ()
    2. The select is part of a set operations. eg. UNION, EXCEPT,
    INTERSECT
    3. (optional) The datatype of the corresponding columns in the
    UNION are not the same.
    
    Example scenario:
    create table tab1(c1 bigint);
    create table tab2(c1 smallint);
    create table tab3(c1 smallint);
    
    Query 1:
    (SELECT 1 FROM tab1)
    EXCEPT
    (SELECT sum(c1) over () FROM tab2);
    
    Query 2:
    (select count(c1) over () from tab3 t3
    UNION
    select c1 from tab2 t2)
    UNION
    select c1 from tab1 t1;
    

Local fix

  • 1. Explicitly rewrite the query to push down the OLAP function
    into a subselect.
    2. Perform an explicit cast to make all the branches of same
    datatype.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * All                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Please upgrade to DB2 version 970 fix pack 8                 *
    ****************************************************************
    

Problem conclusion

  • Problem is fixed in DB2 version 970 fix pack 8
    

Temporary fix

Comments

APAR Information

  • APAR number

    IC87978

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    970

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-11-05

  • Closed date

    2013-04-01

  • Last modified date

    2013-04-01

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

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

    IC89723

Fix information

  • Fixed component name

    DB2 FOR LUW

  • Fixed component ID

    DB2FORLUW

Applicable component levels

  • R970 PSN

       UP

  • R970 PSY

       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":"9.7","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
01 April 2013