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 > Informix > Wrong resultset

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-21-11, 11:02
fmalmeida fmalmeida is offline
Registered User
 
Join Date: Jul 2009
Posts: 12
Wrong resultset

Hi everybody...

I'm facing a strange situation, at least to me..
I have a query like the following one:

select field1, field2, field3
from table
where field1 = 1100004
and field2 = '226630'
order by field3

This query doesn't return any record, however if I replace

and field2 = '226630'

by

and field2 = 226630

, i.e., the compared value without quotes, it already returns a record. The weird thing is that field2 is a char(11) field.
Any tip? I really don't know what it could be.

Best Regards.
Reply With Quote
  #2 (permalink)  
Old 09-20-11, 03:41
rgomezs rgomezs is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Hi.

The problem is that your field is CHAR(11) and when you queries for '226630',
you´re looking exactly for that chain but item in fact is stored as '226630 ' (with 5 trailing blanks).
When you queries for 226630 (as numeric value), Informix autocast the value to match CHAR(11) and converts it to '226630 ".

Kind regards.
Reply With Quote
  #3 (permalink)  
Old 09-20-11, 03:43
rgomezs rgomezs is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
I´m sorry but in my last post, text editor has cutted trailin blanks in fields. Stored value is "226630.....", where each "." means a space.
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