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

Re: DBI "drop table"

by radiantmatrix (Parson)
on Apr 15, 2008 at 18:25 UTC ( #680614=note: print w/ replies, xml ) Need Help??

in reply to DBI "drop table"

As others have said, placeholders are for data -- table names are not data. Kudos, though, for thinking about placeholders and the implication that you care about safety in DBI-based scripts!

What you want in this case is quote_identifier to properly quote the table name, then inline that into a do:

sub drop { my ($dbh, $table_name) = @_; my $quoted_name = $dbh->quote_identifier($table_name); $dbh->do("DROP TABLE $quoted_name"); }

This would be called as drop($dbh,'perl'); to drop a table named 'perl'.

Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Comment on Re: DBI "drop table"
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-11-28 12:08 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 (741 votes), past polls