http://www.perlmonks.org?node_id=852705


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)

Replies are listed 'Best First'.
Re^2: DBI Format Question
by ikegami (Patriarch) 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");