DB2 - Problem description
Problem IT19202 | Status: Closed |
DB2 MAY ISSUE SQL0119N WHEN REFERENCING A CORRELATED COLUMN INSIDE A SCALAR AGGREGATE FUNCTION | |
product: | |
DB2 FOR LUW / DB2FORLUW / B10 - DB2 | |
Problem description: | |
DB2 may incorrectly issue a SQL0119N when a scalar aggregate function references a correlated column. This can happen when there are at least two scalar aggregate functions with correlated column references. Example: SELECT SUM(case when 99 = (SELECT T1.C2 FROM T1 where T1.C1 = T2.C1) then 0 else 1 end), SUM(case when 99 = (SELECT T1.C2 FROM T1 where T1.C1 = T3.C1) then 0 else 1 end) FROM T2, T3 | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 11.1 Mod 2 Fix Pack 2 or higher * **************************************************************** | |
Local Fix: | |
If there is no explicit group by clause, add table references to the correlated columns to eliminate correlation within the scalar aggregate and also add a DISTINCT to the scalar subquery: SELECT SUM(case when 99 = (SELECT DISTINCT T1.C2 FROM T1, T2 where T1.C1 = T2.C1) then 0 else 1 end), SUM(case when 99 = (SELECT DISTINCT T1.C2 FROM T1, T3 where T1.C1 = T3.C1) then 0 else 1 end) FROM T2, T3 | |
available fix packs: | |
DB2 Version 11.1 Mod 2 Fix Pack 2 for Linux, UNIX, and Windows | |
Solution | |
First fixed in DB2 11.1 Mod 2 Fix Pack 2 | |
Workaround | |
not known / see Local fix | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 09.02.2017 28.06.2017 28.06.2017 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |