DBI question: binding params in HAVING clauses
David Cantrell
david at cantrell.org.uk
Thu Jan 26 16:06:43 GMT 2006
On Thu, Jan 26, 2006 at 03:16:04PM +0000, Andy Armstrong wrote:
> On 26 Jan 2006, at 15:01, Jeff Anderson wrote:
> >Like so?
> >my $sql = sprintf('
> > SELECT COUNT(actors.name), countries.name
> > FROM actorsXcountries, countries, actors
> > WHERE actors.id = actorsXcountries.actorid AND
> > countries.id = actorsXcountries.countryid
> > GROUP BY countries.name
> > HAVING COUNT(actors.name) < %d
> > ORDER BY COUNT(actors.name)
> >', $dbh->quote(3));
Oh, so nothing magic.
Using sprintf when we can just interpolate a value into a string seems a
bit like overkill in this case. This is perl, not C!
> What's the point of $dbh->quote() when %d can only expand to an
> integer anyway? Or rather what's the point of using sprintf()?
$dbh->quote(3) expands to '3', which then doesn't work in the HAVING
clause, presumably because it then tries to compare an int to a string.
Do I need to report that as a bug too? :-)
--
David Cantrell | http://www.cantrell.org.uk/david
There are many different types of sausages. The best are
from the north of England. The wurst are from Germany.
-- seen in alt.2eggs...
More information about the london.pm
mailing list