If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Data type conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-08, 05:09
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
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
Reply With Quote
  #2 (permalink)  
Old 08-29-08, 08:47
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
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 --->
Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On