Mary,

   Your error is occuring on this line:

$sth->execute ($sth)

   This line should actually read:

$sth->execute () Anything passed into the execute function is assumed to be a bind variable. Try making that change to your script and run it again.

HTH,
Chris

Mary Anderson wrote:

Hi all,

  This is a reposting of a message.  I was advised that my attached code
did not make it through.

  Basically, I am running ActivePerl 5.8.7 and mySQL 4.1 under windows XP.
Although I can handle data manipulation statements through DBI,  it balks
at drop table and create table statements.  Here is a listing of the code
and my error messages:

#!C:\perl\bin\perl.exe

use strict;
use DBI;

open(STDERR, ">LoadJgan.err");
open(STDOUT, ">LoadJgan.out");
## Remove any old dbi trace logs
unlink 'dbitrace.log' if -e 'dbitrace.log';

my $dbh = DBI->connect("dbi:mysql:meadowrue", "root", "qu3rcus",
         {RaiseError => 0,
          PrintError => 0})
or die "Can't connect to database";
$dbh->trace(2, 'dbitrace.log');

$DropCmd = "drop table IF EXISTS JGanSamples";
my $sth = $dbh->prepare($DropCmd)
     or die "Could not prepare $DropCmd:\n", $dbh->errstr(),"\n";
   $sth->execute ($sth)
     or die "Could not execute $DropCmd:\n", $sth->errstr(),"\n";
......
The error message was:

Could not execute drop table IF EXISTS JGanSamples:
called with 1 bind variables when 0 are needed

Reply via email to