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

Re: Seeking a non-quoted DBI placeholder

by salvadors (Pilgrim)
on Jan 30, 2001 at 21:08 UTC ( [id://55270]=note: print w/replies, xml ) Need Help??


in reply to Seeking a non-quoted DBI placeholder

Anyone know if theres a way to get DBI to not quote a specific placeholder on a statement

Ignoring the flaws that others have already pointed out with your example, it's also worth remembering that DBI will not quote numbers.

This can cause problems when you have a CHAR column to which (sometimes) wish insert numbers. e.g if you had an ISBN column in a book table, the query:

my $find_book = $dbh->prepare(qq{ SELECT title FROM book WHERE isbn = ? });
would be fine when passed
my $isbn = "156884915X"; my $title = $dbh->selectrow_array($find_book, undef, $isbn);
But when passed
my $isbn = 1565922433; my $title = $dbh->selectrow_array($find_book, undef, $isbn);
it won't quote the ISBN. On some databases (definitely on MySQL) this will have the effect of not using the index on this column, massively slowing down this query - particularly if you have the 1.2 million books in print in this table!

Tony

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found