----- Original Message -----
From: "Mary Anderson" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, September 29, 2005 3:00 PM
Subject: Reposting of ActivePerl/MySQL problem dropping tables
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
I believe it should be:
$sth->execute(); # no bind variable
Don't forget scoping:
my $DropCmd = ...