DB2 - Problem description
Problem IC62673 | Status: Closed |
SQL0901N MAY BE ISSUED EXECUTING A QUERY CONTAINING PREDICATES ON MAX OR MIN FUNCTIONS AGGREGATED ON NESTED CASE EXPRESSIONS | |
product: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
Problem description: | |
SQLCODE SQL0901N may be issued while executing a query that satisfies the following conditions: - There is an equality predicate (EQPRD) in the query - One side of EQPRD is either a constant, host-variable or special register (CONST) - The other side of EQPRD is a column derived from the output of a MAX or MIN aggregate function - The MAX or MIN function aggregates the output of a CASE expression (CASEEXP) - CASEEXP has only 1 WHEN clause and either an ELSE NULL or no ELSE clause - The WHEN clause is also an EQPRD (WHENPRD) - One side WHENPRD is CONST - The other side WHENPRD is non-CONST - The THEN clause is a CASE expression (NESTCASE), i.e., nested inside CASEEXP - The THEN and ELSE clause(s) in NESTCASE do not contain expressions An example scenario: -- DDL CREATE TABLE T1 (C1 CHAR(3), C2 VARCHAR(1)); INSERT INTO T1 VALUES ('ABC', 'A'); INSERT INTO T1 VALUES ('BCD', 'B'); -- Query SELECT CASE_COL_1, CASE_COL_2 FROM (SELECT MAX(CASE WHEN C1 = 'ABC' THEN (CASE WHEN C2 = ' ' THEN '-' ELSE C2 END) END) AS CASE_COL_1, MIN(CASE WHEN C1 = 'BCD' THEN (CASE WHEN C2 = ' ' THEN '-' ELSE C2 END) END) AS CASE_COL_2 FROM T1 ) T WHERE CASE_COL_1 = 'A'; -- With just one such column, the -901 will be: SQL0901N The SQL statement failed because of a non-severe system error. Subsequent SQL statements can be processed. (Reason "no cast fcn".) SQLSTATE=58004 -- Otherwise, it will be: SQL0901N The SQL statement failed because of a non-severe system error. Subsequent SQL statements can be processed. (Reason "sqlridummy: invalid opcode 8 at offset <nnnn:n>".) SQLSTATE=58004 | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * EE or EEE * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description. * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 Version 9.7 Fix Pack 1. * **************************************************************** | |
Local Fix: | |
Rewrite EQPRD to a semantically equivalent non-relational-operator form. For the query above, this may be done like so: SELECT CASE_COL_1, CASE_COL_2 FROM (SELECT MAX(CASE WHEN C1 = 'ABC' THEN (CASE WHEN C2 = ' ' THEN '-' ELSE C2 END) END) AS CASE_COL_1, MIN(CASE WHEN C1 = 'BCD' THEN (CASE WHEN C2 = ' ' THEN '-' ELSE C2 END) END) AS CASE_COL_2 FROM T1 ) T WHERE CASE_COL_1 IN ('A', 'A'); | |
available fix packs: | |
DB2 Version 9.7 Fix Pack 1 for Linux, UNIX, and Windows | |
Solution | |
Problem was first fixed in DB2 Version 9.7 Fix Pack 1. | |
Workaround | |
not known / see Local fix | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 20.08.2009 19.02.2010 19.02.2010 |
Problem solved at the following versions (IBM BugInfos) | |
9.7.FP1 | |
Problem solved according to the fixlist(s) of the following version(s) | |
9.7.0.1 |