DB2 - Problem description
Problem IT18381 | Status: Closed |
DB2 MAY RETURN INCORRECT RESULTS IF USING A CASE STATEMENT TO COMPARE FIXED CHAR/GRAPHIC STRINGS IN VARCHAR2 COMPATIBILITY MODE | |
product: | |
DB2 FOR LUW / DB2FORLUW / B10 - DB2 | |
Problem description: | |
When comparing fixed character or graphic strings where either side uses a CASE statement, DB2 may return incorrect results in VARCHAR2 compatibility mode. Example: CREATE TABLE T(C1 CHAR(4)) INSERT INTO T VALUES ('M') SELECT * FROM T WHERE C1 = CASE WHEN 1=1 THEN 'M' END Incorrect Result: C1 ---- 0 record(s) selected. | |
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: | |
From the example above, cast the CASE statement to a fixed character string of the desired length: SELECT * FROM T WHERE C1 = CAST((CASE WHEN 1=1 THEN 'M' END) AS CHAR(1)) C1 -------- M 1 record(s) selected. | |
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 : | 13.12.2016 23.06.2017 23.06.2017 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |