Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: DBI Format Question

by jeffa (Bishop)
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! :)


(the triplet paradiddle with high-hat)

Comment on Re: DBI Format Question
Select or Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2015-11-27 03:36 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (717 votes), past polls