Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 66127
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: bruce.desertrat [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.617



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
On Thu Feb 24 11:06:00 2011, bruce.desertrat wrote: Show quoted text
> 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. > > ----------------------------------------------------------------------
---------- Show quoted text
> > > 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
Hi Bruce, I think that example is missing a ShowErrorStatement => 1 in the connect. Also, I think it is an issue in DBI not DBD::Oracle. Would you mind if I moved it to the DBI rt queue? Martin -- Martin J. Evans Wetherby, UK
Subject: Re: [rt.cpan.org #66127] Error report bug in 'DBD::Oracle::st execute failed:' message
Date: Thu, 24 Feb 2011 12:00:12 -0700
To: bug-DBD-Oracle [...] rt.cpan.org
From: Bruce Johnson <bruce.desertrat [...] gmail.com>
On Feb 24, 2011, at 9:30 AM, Martin J Evans via RT wrote: Show quoted text
> > Hi Bruce, > > I think that example is missing a ShowErrorStatement => 1 in the > connect.
Adding that to the connect statement doesn't change the error output. $dbh = DBI->connect("dbi:Oracle:$dbname", $login, $dbpass, {ShowErrorStatement => 1}); still gives the same error output as shown. Show quoted text
> > Also, I think it is an issue in DBI not DBD::Oracle. Would you mind if I > moved it to the DBI rt queue?
Tim Bunce told me to report it as a DBD::Oracle error. If it properly belongs in DBI go ahead. -- Bruce Johnson If the States are the Laboratories of Democracy, Arizona is the Meth Lab
On Thu Feb 24 14:00:25 2011, bruce.desertrat wrote: Show quoted text
> > On Feb 24, 2011, at 9:30 AM, Martin J Evans via RT wrote: >
> > > > Hi Bruce, > > > > I think that example is missing a ShowErrorStatement => 1 in the > > connect.
> > Adding that to the connect statement doesn't change the error output. > > $dbh = DBI->connect("dbi:Oracle:$dbname", $login, $dbpass, > {ShowErrorStatement => 1}); > > still gives the same error output as shown. >
What I meant was that you don't get that output at all without ShowErrorStatement => 1. It is ShowErrorStatement which adds the SQL and parameters to the error. Show quoted text
> > > > Also, I think it is an issue in DBI not DBD::Oracle. Would you mind
> if I
> > moved it to the DBI rt queue?
> > Tim Bunce told me to report it as a DBD::Oracle error. If it properly > belongs in DBI go ahead. >
I didn't read his email like that but never the less I pretty sure is a DBI issue and not a DBD::Oracle issue (you can see it in other drivers - same happens with DBD::ODBC) so I'll move it and we'll see what he says. Martin -- Martin J. Evans Wetherby, UK
Subject: Re: [rt.cpan.org #66127] Error report bug in 'DBD::Oracle::st execute failed:' message
Date: Fri, 25 Feb 2011 11:18:03 +0000
To: Martin J Evans via RT <bug-DBD-Oracle [...] rt.cpan.org>
From: Tim Bunce <Tim.Bunce [...] pobox.com>
On Fri, Feb 25, 2011 at 03:39:13AM -0500, Martin J Evans via RT wrote: Show quoted text
> > > > > > Also, I think it is an issue in DBI not DBD::Oracle. Would you mind if I > > > moved it to the DBI rt queue?
> > > > Tim Bunce told me to report it as a DBD::Oracle error. If it properly > > belongs in DBI go ahead.
> > I didn't read his email like that but never the less I pretty sure is a > DBI issue and not a DBD::Oracle issue (you can see it in other drivers - > same happens with DBD::ODBC) so I'll move it and we'll see what he says.
I think the arg-count check in execute() is performed in the drivers. Each needs fixing. Tim.
On Fri Feb 25 06:18:13 2011, Tim.Bunce@pobox.com wrote: Show quoted text
> On Fri, Feb 25, 2011 at 03:39:13AM -0500, Martin J Evans via RT wrote:
> > > > > > > > Also, I think it is an issue in DBI not DBD::Oracle. Would you
> mind if I
> > > > moved it to the DBI rt queue?
> > > > > > Tim Bunce told me to report it as a DBD::Oracle error. If it
> properly
> > > belongs in DBI go ahead.
> > > > I didn't read his email like that but never the less I pretty sure
> is a
> > DBI issue and not a DBD::Oracle issue (you can see it in other
> drivers -
> > same happens with DBD::ODBC) so I'll move it and we'll see what he
> says. > > I think the arg-count check in execute() is performed in the drivers. > Each needs fixing. > > Tim.
I can only find it in Driver_xst.h in DBI: static int dbdxst_bind_params(SV *sth, imp_sth_t *imp_sth, I32 items, I32 ax) { /* Handle binding supplied values to placeholders. */ /* items = one greater than the number of params */ /* ax = ax from calling sub, maybe adjusted to match items */ dTHX; int i; SV *idx; if (items-1 != DBIc_NUM_PARAMS(imp_sth) && DBIc_NUM_PARAMS(imp_sth) != DBIc_NUM_PARAMS_AT_EXECUTE ) { char errmsg[99]; sprintf(errmsg,"called with %d bind variables when %d are needed", (int)items-1, DBIc_NUM_PARAMS(imp_sth)); sv_setpv(DBIc_ERRSTR(imp_sth), errmsg); sv_setiv(DBIc_ERR(imp_sth), (IV)-1); return 0; } I may have missed something but I certainly cannot find "called with" in DBD::ODBC. Martin -- Martin J. Evans Wetherby, UK
CC: bruce.desertrat [...] gmail.com, TIMB [...] cpan.org
Subject: Re: [rt.cpan.org #66127] Error report bug in 'DBD::Oracle::st execute failed:' message
Date: Sun, 27 Feb 2011 18:38:03 +0000
To: Martin J Evans via RT <bug-DBI [...] rt.cpan.org>
From: Tim Bunce <Tim.Bunce [...] pobox.com>
On Fri, Feb 25, 2011 at 02:18:01PM -0500, Martin J Evans via RT wrote: Show quoted text
> I can only find it in Driver_xst.h in DBI:
Ah, yes. You're right. The ticket should be in the DBI queue. Thanks Martin! Tim.
On Sun Feb 27 13:38:21 2011, Tim.Bunce@pobox.com wrote: Show quoted text
> On Fri, Feb 25, 2011 at 02:18:01PM -0500, Martin J Evans via RT wrote:
> > I can only find it in Driver_xst.h in DBI:
> > Ah, yes. You're right. The ticket should be in the DBI queue. > Thanks Martin! > > Tim.
Test added to subversion trunk to show this problem. Martin -- Martin J. Evans Wetherby, UK
Relevant link to a possible fix: http://www.mail-archive.com/dbi-users@perl.org/msg33769.html -- Martin J. Evans Wetherby, UK
I've patched the source (r15061). This will need testing by driver authors.