Subject RE: [ib-support] Strange query results, based on where clause
Author Leyne, Sean
> For those who haven't followed this closely, given
> that f1 is a character field with a value of '0617',
> f1 = 617 is true if f1 is not indexed (or if the
> index is not used) and false when the query is
> evaluated through an index. The 617 part is not
> significant - the problem is the leading zero in
> the character string.

...

> So, should '617' = 617?
> How about '0617' = 617?
> Or '0617' = 0617?

I think of this problem a little like ambiguity in SELECT statements --
it should be avoided at all cost.

Therefore, to my mind, the solution is to make the unindexed result
consistent. Meaning:
- '0617' <> 617 and
- '617' = 617
but
- '0617' <> 0617 and
- '617' = 0617.

The fact that the engine will convert integer values to strings is a
convenience, it doesn't absolve the developers from using a little
common sense when performing selects.


Sean