baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
and in it i'm trying to create a sub that would drop the table whenever i call it. so if i'd like to drop the table named "perl" i would write drop(perl). i tried to resolve the problem with placeholders but it is not working. any suggestions would be usefull.use strict; use DBI; use Data::Dumper; my $driver = "mysql"; my $dns = "database=baxy"; my $username = "baxy"; my $password = ""; my $dbh = DBI -> connect ("dbi:$driver:$dns", $username, $password, {A +utoCommit => 1}); my $s = 'perl'; drop($s); my $sth = $dbh->prepare ("create table perl(id INTEGER NOT NULL, name VARCHAR (255), title VARCHAR (255), ph VARCHAR (255) )") || die "$DBI::errstr"; $sth -> execute()|| die "$DBI::errstr"; sub drop{ my $r = $_[0]; my $sti = $dbh->prepare("drop table ?"); $sti -> execute($r) || die"$DBI::errstr"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI "drop table"
by moritz (Cardinal) on Apr 12, 2008 at 19:01 UTC | |
by ikegami (Patriarch) on Apr 12, 2008 at 20:32 UTC | |
by tinita (Parson) on Apr 13, 2008 at 11:18 UTC | |
|
Re: DBI "drop table"
by GrandFather (Saint) on Apr 12, 2008 at 20:23 UTC | |
|
Temporary table instead? (was DBI "drop table")
by doom (Deacon) on Apr 13, 2008 at 06:49 UTC | |
|
Re: DBI "drop table"
by DBAugie (Beadle) on Apr 13, 2008 at 13:09 UTC | |
|
Re: DBI "drop table"
by radiantmatrix (Parson) on Apr 15, 2008 at 18:25 UTC |