Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Pune , India

    Unanswered: Data type conversion

    sort of confuse
    i have a column PPLTESTTTID (Bigint ) with 1 row having value 13010,

    select * from eone.TTT where PPLTESTTTID= 13010.0

    returns me the row, shouldnt it fail ?

    If that mean that a automatic conversion / round of happens?
    but then why it doesnt return any row for 13010.1

    db2 9 on windows

  2. #2
    Join Date
    Feb 2008
    The rules are troublesome and not easy to find them.
    But, they were clearly described in
    "DB2 SQL Reference Volume 1" ---> Chapter 2. Language elements ---> Assignments and comparisons --->
    Numeric comparisons
    Numbers are compared algebraically; that is, with regard to sign. For example, −2 is less than +1.

    If one number is an integer and the other is decimal, the comparison is made with a temporary copy of the integer, which has been converted to decimal.

    When decimal numbers with different scales are compared, the comparison is made with a temporary copy of one of the numbers that has been extended with trailing zeros so that its fractional part has the same number of digits as the other number.

    If one number is floating-point and the other is integer or decimal, the comparison is made with a temporary copy of the other number, which has been converted to double-precision floating-point.

    Two floating-point numbers are equal only if the bit configurations of their normalized forms are identical.
    So, the comparison must be done by decimal in your case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts