Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: DBI: when 1 != '1'by bart (Canon) |
on Sep 27, 2002 at 23:55 UTC ( [id://201386]=note: print w/replies, xml ) | Need Help?? |
I'll pass on the ability of Perl to distinguish between 1 and '1'. To my knowledge there's no way to separate themBut there is: for bitwise operators like "&" and "|", strings behave differently than numbers. If one is a number, both will be treated as a number. For example will produce a different result for 1 and for "1". Coming back to DBI: It doesn't make this kind of distinction IIRC. Anything is a string. Binding placeholders to a variable type can help. I don't know for sure for enumerated types in MyQSL, I can't test that (easily), but I do recall that DBI appears to make a guess on a field type based on the first value you feed it. If it looks like a number, DBI will treat the column as a number, which will produce an error if the field contains a non-numerical value for one of the next rows. I think even that if the first value is undef, DBI treats it as a string... And various MS databases do mind, even if MySQL doesn't. This prevents that:
p.s. Disclaimer: this is all based on my memory of experiences of a few years ago. Please don't hold it too much against me if it contains a few minor errors.
In Section
Meditations
|
|