Re: 'Clever' behaviour
Posted in 1996
On 26 Jun 1996, Ken Miles wrote:
>
> Which is to say "Remember your quotes or suffer the consequences!" I too
> wish there were a way to control how Informix will try to assume what
> we mean and let us define certain rules for implicit type conversion. We
> have lost a lot of time chasing subtle bugs like the queries below. They
> both parse just fine but they return different results.
>
> select * from stores:orders where order_date = 07/24/1994 ;
> select * from stores:orders where order_date = '07/24/1994'; You can also try = mdy( 7,24,1994);
or = "7/24/1994";
BTW, these last two give correct results. The first is probably
trying to do a division 7 divided by 24 and possibly coming up with
a numeric result that the database attempts to cast the result back
to a date type (my imagination is running amok ... again). I tried
it with a count (*) and got 0 rows. It's amusing because it seems
to work, and if you're falling into that post lunch afternoon stupor,
it may even look reasonable, like "Hey, that's cool, Informix knows
instinctively that this is a date type and handles the rest for you.
(Informix [aside] cackle, cackle...)
> Ken Miles
> kenm@vcd.hp.com
> Opinions my own and all other standard disclaimers.
>