Subject: | Error report bug in 'DBD::Oracle::st execute failed:' message |
The error message for a failed $cursor->execute() statement with insufficient bind variables lists the bind variables for the last good execution of
the execute statement, as with a $csr->execute($foo, $bar,$baz); statement in a loop.
Example code:
---------------------------------------------------------------------
#!/usr/bin/perl
use DBI;
$login="login";
$dbpass="pass";
$dbname="host=hostname;sid=sidname";
# Create table statement
$sqcreate = <<SQ;
create table test (
foo varchar2(10),
bar varchar2(10),
baz number)
SQ
$sql = "insert into test (bar, baz, foo) values (?,?,?)";
$dbh = DBI->connect("dbi:Oracle:$dbname", $login, $dbpass);
$dbh->do($sqcreate) or die $dbh->errstr;
$csr = $dbh->prepare($sql) or die $dbh->errstr;
$parms{1}{'foo'}="Bill";
$parms{1}{'bar'}="Kaboom";
$parms{1}{'baz'}=123;
$parms{2}{'foo'}="Mike";
$parms{3}{'foo'}="Jane";
$parms{3}{'bar'}="Kuunch";
$parms{4}{'foo'}="Alice";
$parms{4}{'bar'}="Dorrp";
$parms{4}{'baz'}=456;
$parms{5}{'foo'}="Pat";
$parms{5}{'bar'}="PaDing";
for ($i=1;$i<6;$i++){
@inparms =();
print "inserting data for $parms{$i}{'foo'}\n";
foreach $k(sort keys %{$parms{$i}}){
push @inparms, $parms{$i}{$k};
}
$csr->execute(@inparms);
}
exit;
------------------------------------------------
And the error:
host command> ./testofparamarray.pl
inserting data for Bill
inserting data for Mike
DBD::Oracle::st execute failed: called with 1 bind variables when 3 are needed [for Statement "insert into test (bar, baz, foo) values (?,?,?)" with
ParamValues: :p1='Kaboom', :p2=123, :p3='Bill'] at ./testofparamarray.pl line 44.
inserting data for Jane
DBD::Oracle::st execute failed: called with 2 bind variables when 3 are needed [for Statement "insert into test (bar, baz, foo) values (?,?,?)" with
ParamValues: :p1='Kaboom', :p2=123, :p3='Bill'] at ./testofparamarray.pl line 44.
inserting data for Alice
inserting data for Pat
DBD::Oracle::st execute failed: called with 2 bind variables when 3 are needed [for Statement "insert into test (bar, baz, foo) values (?,?,?)" with
ParamValues: :p1='Dorrp', :p2=456, :p3='Alice'] at ./testofparamarray.pl line 44.
--------------------------------------------------------------------------------
Environment:
OS: Linux tonic 2.6.16.60-0.34-bigsmp #1 SMP Fri Jan 16 14:59:01 UTC 2009 i686 i686 i386 GNU/Linux
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
DBI (1.607) - Database independent interface for Perl
DBD::Oracle (1.22) - Oracle database driver for the DBI module
perl --version
This is perl, v5.10.0 built for i686-linux