suche 36x36
Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IT21948 Status: Closed

DB2 MAY RETURN WRONG RESULTS WITH ORACLE COMPATIBILITY AND SUBSTR

product:
DB2 FOR LUW / DB2FORLUW / B10 - DB2
Problem description:
DB2 may return wrong results when all the following conditions 
are met: 
-The database has oracle compatibility 
(DB2_COMPATIBILITY_VECTOR=ORA) mode enabled. 
-The SELECT query being issued contains a relational operator 
predicate with SUBSTR. 
-The string argument to SUBSTR is from a table that has an index 
on that column. 
-The other operand of the relational operator is a literal. 
 
This forces the optimizer to perform an index scan using only 
the 
start/stop predicates. The index scan LOLEPOP does not contain 
the SUBSTR predicate, only the start/stop preds. 
 
Example: 
 
create table t (v VARCHAR(128)); 
create index i on t(v); 
insert into t values 'PT1', 'PT10'; 
 
select v from t where substr(v, 1, 20) = cast('PT1' as 
VARCHAR(20)); 
 
The above query returns two rows ('PT1', 'PT10') when we should 
only 
be returning one ('PT1'). 
 
The expected result (one row) is returned by the following: 
 
select v from t where v = cast('PT1' as VARCHAR(20));
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* ALL                                                          * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to Db2 11.1 Mod 2 Fix Pack 2 iFix002 or higher       * 
****************************************************************
Local Fix:
Workaround: 
 
Replace the literal with a table column or variable. 
Continuing with the example above: 
 
create variable myvar char(3) default 'PT1'; 
select * from test where substr(v, 1, 20) = myvar;
available fix packs:
Db2 Version 11.1 Mod2 Fix Pack2 iFix002 for Linux, UNIX, and Windows
Db2 Version 11.1 Mod 3 Fix Pack 3 for Linux, UNIX, and Windows
Db2 Version 11.1 Mod3 Fix Pack3 iFix001 for Linux, UNIX, and Windows
Db2 Version 11.1 Mod3 Fix Pack3 iFix002 for Linux, UNIX, and Windows

Solution
First fixed in Db2 11.1 Mod 2 Fix Pack 2 iFix002
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
09.08.2017
22.12.2017
22.12.2017
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)