On 18.05.2009 15:42, Tod A. Sandman wrote:
On Sat, May 16, 2009 at 06:07:05PM +0200, Alexander Foken wrote:
Perl silently converts Integers to Floats to prevent integer overflow.
Unless you have a perl with 64 Bit integers (see perl -V), this may bite
you here: You get the usual floating point rounding issues. If you
explicitly convert the bigint to a string already in the database, so
that perl reads and writes a string, the problem should disappear.
Something like
SELECT TOCHAR(token) FROM table WHERE foo=?
and
SELECT bar,baz FROM table WHERE TOCHAR(token)=?
or
SELECT bar,baz FROM table WHERE token=TOBIGINT(?)
Thanks.
I tried using "TOCHAR" verbatim (I'm ultra weak in sql), but I got a
mysql syntax error (I'm using mysql-4.1.22).
Yes, TOCHAR is what I've remembered from Oracle. But it wouldn't work
there, because its spelled TO_CHAR. It seems there is no standard in SQL
for converting data types, each RBDMS has its own way.
But using
"SELECT CONVERT(token, CHAR) seems to work fine:
$query = "SELECT CONVERT(token, CHAR),spam_hits,innocent_hits
from dspam_token_data where uid = $uid";
..........
$query = "UPDATE dspam_token_data set spam_hits = ?,
innocent_hits = ? where (uid = $uid) and
(CONVERT(token, CHAR) = ?)";
Good to know.
Thanks for the feedback,
Alexander
--
Alexander Foken
mailto:[email protected] http://www.foken.de/alexander/