develooper Front page | perl.beginners | Postings from February 2002

Perl DBI - using parameters

Thread Next
McElwee, Shane
February 1, 2002 09:14
Perl DBI - using parameters
Message ID:

This is my first effort at perl scripting so forgive my innocence. What I am
trying to do is extract schema and data info from a proprietary database
into flat files, format those files and import the data and schema into an
Oracle database. 

The initial part of this is capturing the table names into an array and then
using that array to query the database and dump the results to flat files.
Where I'm having trouble is in using a bound parameter in the sql statement.
If I use a table name directly it works without a problem but when I
parameterise it I get a Parse Error.

foreach $i (@table_arr){
      $content = $i;
#     print ("table name is:  $i \n");
      open( CONTENT, ">$content" ) || die "Can't open file $content";
      my $sth = $dbh->prepare("select * from ?");
      $sth->bind_param(1, $i);

      my $row;

      $sth->execute or die "Can't execute SQL statement: ", $sth->errstr(),
      $row = $sth->dump_results(80, "\n", ':',\*CONTENT);

Any ideas where I could be going wrong?



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About