Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: DBI Format Question

by jeffa (Chancellor)
on Aug 03, 2010 at 17:33 UTC ( #852705=note: print w/ replies, xml ) Need Help??


in reply to DBI Format Question

You cannot use placeholders for table names like that. You'll have to instead interpolate inside the string. It's ok, though, you are not dealing with user input here.

$dbh->prepare( "select stuff from $table");

Having to use table names like that is a challenge too. I would look into renaming those tables and removing the dashes if that is an option and a viable one at that. Good luck! :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re: DBI Format Question
Select or Download Code
Re^2: DBI Format Question
by ikegami (Pope) on Aug 03, 2010 at 18:50 UTC
    You can't use placeholders because table names must be known when the query is prepared. That leaves using a quoting function.
    my $q_table = $dbh->quote_identifier($table); $dbh->prepare("select stuff from $q_table");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2014-11-26 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls