When you prepare a statement and use placeholders (?), they can only be used for parameters such as "insert into sometable values ( ?, ?, ? )" or "where somevar = ?". The parameters are bind to the statement when it is executed, which means it must successfully being prepared already.
The do method is better in your case because your are not using parameters, but using a perl variable in the name of the table. Since "create table tableno? ( .... )" is not valid, you would need to prepare and execute every time or just do(). -- Jess > -----Original Message----- > From: Ramprasad [mailto:[EMAIL PROTECTED] > Sent: Thursday, July 17, 2003 10:22 AM > To: [EMAIL PROTECTED]; Rob Dixon > Cc: [EMAIL PROTECTED] > Subject: Re: DBI execute problem > > > > Hi Ram. > > > > If all you're doing is to create a number of tables then I'd > > get Perl to write the whole SQL statement for you and just > > > > $dbh-do($sql) > > > > Even so, what you've written is weird. You're creating a > set of thirty > > tables, each with two character columns with a maximum length equal > > to the table number. Is this just an example? > > You are right it is weird. But just a test script to learn > DBI. What I > really want is how Can I use prepare and execute which I > think is better > than doing a do every time If my table name keeps changing > > Is a prepare statement always specific to a table in a database ? > > I mean Cant I do > ......... > $sth=$dbh->prepare("insert into ? (word,wkey) values ( ? , ?)") > foreach $word ( @list) { > my $tablename = "w" . length($word); > $sth->execute($tablename,$word,foo($word)) || die $dbh->errstr; > # $tablename gets quoted here and gives error > } > ........ > > I have been using perl with Mysql module and now I want to > shift to DBI > > > Thanks > Ram > > > > > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]