On Feb 18, 2011, at 1:55 PM, Bruce Johnson wrote:
> Figured it out.
>
> The second ldap query did not return all the attributes I was looking for,
> and when it returned no value for that attribute, the bind variable wasn't
> populated, leading to the mismatch between expected and actual. The error is
> correct.
>
> The error MESSAGE, however contained the last known value for that number
> bind variable, which may be a bug.
I wasn't quite correct, the error message actually lists the parameter values
of the last successful insert statement.
Here is a test script that demonstrates the problem. (I saw this on oracle,
dunno if it's actually a DBD oracle issue or a DBI issue.)
-------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
use DBI;
$login="<useyourown>";
$dbpass="<useyourown>";
$dbname="host=server.name;sid=sid_name";
# 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 =();
foreach $k(sort keys %{$parms{$i}}){
push @inparms, $parms{$i}{$k};
}
$csr->execute(@inparms);
}
exit;
------------------------------------------------------------------------------------------------------
This is the output of this script:
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
43.
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
43.
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
43.
My environment is:
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
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs