Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Problem with DBD::CSV

by kennethk (Monsignor)
on Apr 09, 2013 at 18:26 UTC ( #1027799=note: print w/ replies, xml ) Need Help??


in reply to Problem with DBD::CSV

As choroba accurately points out, by missing quotes around Big, you are telling the SQL engine to return where the values in the columns named size and Big match, not where the value in column size is Big. That SQL would look like

SELECT animal FROM animals WHERE size = 'Big'
However, the better solution here is to use Placeholders and Bind Values. This way, the SQL engine handles the quoting and escaping for you, so you don't have to worry about what you are feeding it.
my $sth = $dbh->prepare(qq{ SELECT animal FROM animals WHERE size = ? }); $sth->execute('Big') or die "Cannot execute: " . $sth->errstr();

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: Problem with DBD::CSV
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027799]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-12-25 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls