IBM Support

IT16575: SQLCODE -120 WHEN UDF WITH DEFAULT VALUE used WITHIN AN AGGREGATE FUNCTION IN SQL PL or PL/SQL

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as fixed if next.

Error description

  • When a UDF is invoked with a default parameter (either
    implicitly or explicitly), and the UDF is itself an argument to
    an aggregate function, and the query is within SQL PL or PL/SQL,
    SQLCODE -120 may be returned, e.g.:
    
        CREATE OR REPLACE FUNCTION fdef(
          IN p_int integer default 9909 )
        RETURNS integer
        LANGUAGE SQL NO EXTERNAL ACTION
        DETERMINISTIC
          BEGIN
          RETURN p_int; --
          END
        DB20000I  The SQL command completed successfully.
    
        create or replace function f()
        returns int
        language sql
        BEGIN
          DECLARE l_rtn CURSOR; --
          DECLARE result int; ---
          SET l_rtn = CURSOR FOR SELECT max(FDEF(DEFAULT))
                                 FROM T group by col1; --
          OPEN l_rtn; --
          fetch l_rtn into result; --
          CLOSE l_rtn; --
          return result; --
        END
        SQL0120N  Invalid use of an aggregate function or OLAP
    function.
    

Local fix

  • Do not make use of the DEFAULT value, add an explicit argument.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * ALL                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to Db2 version 11.5.5                                *
    ****************************************************************
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    IT16575

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    B10

  • Status

    CLOSED FIN

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2016-08-11

  • Closed date

    2021-02-18

  • Last modified date

    2021-02-18

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

    IT07004

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

Fix information

Applicable component levels

[{"Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1"}]

Document Information

Modified date:
26 February 2021