On Feb 21, 2011, at 11:11 AM, Bruce Johnson wrote:

> 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.

Here is a somewhat clearer one that tells you what data we're trying to insert:

-----------------------------------------
#!/usr/bin/perl
use DBI;

$login="pharmmail";
$dbpass="nhy329";
$dbname="host=tonic.pharmacy.arizona.edu;sid=phmweb";

# 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:

oraweb@tonic:~/perl/pharmmail> ./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.



-- 
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs


Reply via email to