home clear 64x64
en blue 200x116 de orange 200x116 info letter User
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 IC83446 Status: Closed

INCORRECT RESULTS USING VARCHAR_FORMAT (TO_CHAR) TO CONVERT NUMERIC VALUES
TO FORMATTED STRINGS

product:
DB2 FOR LUW / DB2FORLUW / 980 - DB2
Problem description:
Incorrect results can be obtained for several VARCHAR_FORMAT 
usage scenarios. Examples of these scenarios are as follows: 
 
1. Numeric input between -1 and 1 is formatted incorrectly for 
several scenarios: 
 
VALUES VARCHAR_FORMAT (DECFLOAT (0.123),'.999'); 
Current result : '#####' 
Expected result: ' .123' 
VALUES VARCHAR_FORMAT (DECFLOAT (-0.1), '.99'); 
Current result : '####' 
Expected result: '-.10' 
VALUES VARCHAR_FORMAT (DECFLOAT (0.123), '9.999'); 
Current result : ' 0.123' 
Expected result: '  .123' 
 
2. Extra '#' in output, when explicit sign tokens such as 'S', 
'MI' or 'PR' are included in the format string, and the input 
cannot be formatted due to overflow. 
 
Examples: 
VALUES VARCHAR_FORMAT(-321, 'S99'); 
Current result : '####' 
Expected result: '###' 
VALUES VARCHAR_FORMAT(-21, 'S99'); 
Result : '-21'  -- Correct result and notice that length is 3 
bytes. 
VALUES VARCHAR_FORMAT(-321, '99PR'); 
Current result : '#####' 
Expected result: '####' 
VALUES VARCHAR_FORMAT(-321,'99MI'); 
Current result : '####' 
Expected result : '###' 
VALUES VARCHAR_FORMAT(1, 'S'); 
Current result : '##' 
Expected result: '#' 
 
3. Special values such as positive and negative Infinity, NaN 
and sNaN are returned differently when VARCHAR_FORMAT is used 
with and without a format string specified. For support across 
DB2 family of products, these values should be capitalized (i.e. 
behave like the NO_FORMAT case below). 
 
SELECT VARCHAR(VARCHAR_FORMAT(c1),15) AS NO_FORMAT, 
VARCHAR(VARCHAR_FORMAT(c1, '99'),15) AS WITH_FORMAT FROM (VALUES 
nan,-nan,snan,-snan,infinity,-infinity) AS X(c1) 
 
NO_FORMAT  WITH_FORMAT 
--------------- --------------- 
NAN              NaN 
-NAN            -NaN 
SNAN            sNaN 
-SNAN          -sNaN 
INFINITY      Infinity 
-INFINITY      -Infinity 
 
6 record(s) selected.
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* VARCHAR_FORMAT (TO_CHAR)  users                              * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* Incorrect results can be obtained for several VARCHAR_FORMAT * 
* usage scenarios. Examples of these scenarios are as follows: * 
*                                                              * 
* 1. Numeric input between -1 and 1 is formatted incorrectly   * 
* for                                                          * 
* several scenarios:                                           * 
*                                                              * 
* VALUES VARCHAR_FORMAT (DECFLOAT (0.123),'.999');             * 
* Current result : '#####'                                     * 
* Expected result: ' .123'                                     * 
* VALUES VARCHAR_FORMAT (DECFLOAT (-0.1), '.99');              * 
* Current result : '####'                                      * 
* Expected result: '-.10'                                      * 
* VALUES VARCHAR_FORMAT (DECFLOAT (0.123), '9.999');           * 
* Current result : ' 0.123'                                    * 
* Expected result: '  .123'                                    * 
*                                                              * 
* 2. Extra '#' in output, when explicit sign tokens such as    * 
* 'S',                                                         * 
* 'MI' or 'PR' are included in the format string, and the      * 
* input                                                        * 
* cannot be formatted due to overflow.                         * 
*                                                              * 
* Examples:                                                    * 
* VALUES VARCHAR_FORMAT(-321, 'S99');                          * 
* Current result : '####'                                      * 
* Expected result: '###'                                       * 
* VALUES VARCHAR_FORMAT(-21, 'S99');                           * 
* Result : '-21'  -- Correct result and notice that length is  * 
* 3                                                            * 
* bytes.                                                       * 
* VALUES VARCHAR_FORMAT(-321, '99PR');                         * 
* Current result : '#####'                                     * 
* Expected result: '####'                                      * 
* VALUES VARCHAR_FORMAT(-321,'99MI');                          * 
* Current result : '####'                                      * 
* Expected result : '###'                                      * 
* VALUES VARCHAR_FORMAT(1, 'S');                               * 
* Current result : '##'                                        * 
* Expected result: '#'                                         * 
*                                                              * 
* 3. Special values such as positive and negative Infinity,    * 
* NaN                                                          * 
* and sNaN are returned differently when VARCHAR_FORMAT is     * 
* used                                                         * 
* with and without a format string specified. For support      * 
* across                                                       * 
* DB2 family of products, these values should be capitalized   * 
* (i.e.                                                        * 
* behave like the NO_FORMAT case below).                       * 
*                                                              * 
* SELECT VARCHAR(VARCHAR_FORMAT(c1),15) AS NO_FORMAT,          * 
* VARCHAR(VARCHAR_FORMAT(c1, '99'),15) AS WITH_FORMAT FROM     * 
* (VALUES                                                      * 
* nan,-nan,snan,-snan,infinity,-infinity) AS X(c1)             * 
*                                                              * 
* NO_FORMAT  WITH_FORMAT                                       * 
* --------------- ---------------                              * 
* NAN              NaN                                         * 
* -NAN            -NaN                                         * 
* SNAN            sNaN                                         * 
* -SNAN          -sNaN                                         * 
* INFINITY      Infinity                                       * 
* -INFINITY      -Infinity                                     * 
*                                                              * 
* 6 record(s) selected. ?edit                                  * 
* Error Description None                                       * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Install this fix                                             * 
****************************************************************
Local Fix:
Solution
Install this fix
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
14.05.2012
13.06.2012
13.06.2012
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)