DB2 - Problem description
| Problem IC77360 | Status: Closed |
INCORRECT TRUTH VALUE FROM COMPARISON OF TIMESTAMP TO STRING HAVING HIGHER PRECISION THAN THE TIMESTAMP | |
| product: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
| Problem description: | |
In V9.7 the precision of the timestamp operand in a comparison
could be less than the number of fractional seconds in the
string representation of a timestamp. Currently, the comparison
uses the same precision as the timestamp operand, thus
truncating even non-zero fractional seconds digits when
converting the string representation to a timestamp.
For example, the equality predicate TIMESTAMP
'2010-08-18-15.20.25' = '2010-08-18-15.20.25.123' is TRUE
because the left operand has a type of TIMESTAMP(0) and then
converts the right operand to the same, losing the 3 fractional
seconds digits before doing the comparison. The expected result
in this case would be FALSE.
Example of above current using a column:
create table t1 (c1 timestamp(0));
insert into t1 values ('2010-08-18-15.20.25');
select c1 from t1 where c1 = '2010-08-18-15.20.25.123';
C1
-------------------
2010-08-18-15.20.25
Comparisons that involve timestamp values are evaluated
according to the following rules:
- When comparing timestamp values with different precisions,
the higher precision is used for the comparison and any missing
digits for fractional seconds are assumed to be zero.
- When comparing a timestamp value with a string representation
of a timestamp, the string representation is first converted to
TIMESTAMP(12).
- Timestamp comparisons are chronological without regard to
representations that might be considered equivalent. Thus, the
following predicate is true:
TIMESTAMP('1990-02-23-00.00.00') > '1990-02-22-24.00.00' | |
| Problem Summary: | |
| Local Fix: | |
Explicitly cast string into a TIMESTAMP(p) | |
| available fix packs: | |
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows | |
| Solution | |
| Workaround | |
not known / see Local fix | |
| Comment | |
This is a new requirement | |
| Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 06.07.2011 19.01.2012 19.01.2012 |
| Problem solved at the following versions (IBM BugInfos) | |
| Problem solved according to the fixlist(s) of the following version(s) | |
| 9.7.0.5 |
|