MattLG has asked for the wisdom of the Perl Monks concerning the following question:
I'm using a mysql database and I'm finding different results when I query depending on whether I use the search data 'inline' compared to when I use bound data in the execute() subroutine.
The table is called weathercache, with 4 columns, latitude (float), longitude (float), weather(text) and cached(datetime). Both floats are float(8,6).
I can insert the data fine:
use DBI; $dbh = connect(.........); $dbh->prepare('INSERT INTO weathercache (latitude, longitude, weather, + cached) VALUES (?, ?, ?, NOW())')->execute(50.530998, -4.949000, '') +;
But the next line successfully finds this line again if I use:
$sth = $dbh->prepare('SELECT * FROM weathercache WHERE latitude = 50.5 +30998 AND longitude = -4.949000')->execute();
...but not if I use
$sth = $dbh->prepare('SELECT * FROM weathercache WHERE latitude = ? AN +D longitude = ?')->execute(50.530998, -4.949000);
What am I doing wrong here? A float is a float right? Why does it matter how I use it?
Cheers
MattLG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Difference between inline SQL and bound data
by moritz (Cardinal) on May 16, 2010 at 15:30 UTC | |
by JavaFan (Canon) on May 16, 2010 at 20:34 UTC | |
by polettix (Vicar) on May 17, 2010 at 15:46 UTC | |
by MattLG (Beadle) on May 16, 2010 at 17:55 UTC | |
|
Re: Difference between inline SQL and bound data
by ww (Archbishop) on May 16, 2010 at 17:47 UTC |