Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 36395
Status: rejected
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: ramesh.thangamani [...] yahoo.co.in
Cc:
AdminCc:

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



This is the bug which I have posted in forum http://www.nntp.perl.org/group/perl.dbi.users/2007/05/msg31388.html Test Code: ---------- #!/usr/bin/perl use DBI; use Data::Dumper; #DBI->trace(5); my $dbh = DBI->connect("DBI:Oracle:orcl",'scott','tiger') or die "Can't connect to : $DBI::errstr"; $dbh->{RaiseError} = 1; my $sth = $dbh->prepare( q{select ename from emp where empno = ?}) or die "Can't prepare statement: $DBI::errstr"; @bind = (7902); my $rc = $sth->execute(@bind) or die "Can't execute statement: $DBI::errstr"; while ( $row = $sth->fetchrow_arrayref() ) { print Dumper $row; } my @bind1 = (); my $rc = $sth->execute(@bind1) or die "Can't execute statement: $DBI::errstr"; while ( $row = $sth->fetchrow_arrayref() ) { print Dumper $row; } Result ------ $VAR1 = [ 'FORD' ]; $VAR1 = [ 'FORD' ]; If you observe closely you can see that the first the records were retrieved when the bind value was provided. During the second run there was no bind value but still it returns the old result, which i feel shouldn't be the behavior. It should try to error out.
The DBI is acting as defined. It's not a bug. You should avoid using an array to pass arguments to execute().
Subject: Re: [rt.cpan.org #36395]
Date: Wed, 25 Jun 2008 16:44:53 +1000
To: bug-DBI [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Tim On Tue, 2008-06-24 at 17:17 -0400, Tim_Bunce via RT wrote: Show quoted text
> Queue: DBI > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=36395 > > > The DBI is acting as defined. It's not a bug. > You should avoid using an array to pass arguments to execute().
I can't image why I received this email. I have not received any others on DBI. I suggest you report it to the managet of RT. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html
On Tue Jun 24 17:17:23 2008, TIMB wrote: Show quoted text
> The DBI is acting as defined. It's not a bug. > You should avoid using an array to pass arguments to execute().
I could still see the following examples mentioned in the documentation in CPAN where we are passing an array to execute method(). Please comment on this. $rv = $sth->execute or die $sth->errstr; $rv = $sth->execute(@bind_values) or die $sth->errstr;
On Tue Jul 01 01:37:00 2008, RTHANGAM wrote: Show quoted text
> On Tue Jun 24 17:17:23 2008, TIMB wrote:
> > The DBI is acting as defined. It's not a bug. > > You should avoid using an array to pass arguments to execute().
> > I could still see the following examples mentioned in the documentation > in CPAN where we are passing an array to execute method(). Please > comment on this. > > $rv = $sth->execute or die $sth->errstr; > $rv = $sth->execute(@bind_values) or die $sth->errstr;
I was too terse in my reply. If you use an array to pass arguments to execute() you should take care that the number of elements in the array matches the number of placeholders. I've added a note to the docs: Note that passing C<execute> an empty array is the same as passing no arguments at all, which will execute the statement with previously bound values. That's probably not what you want. Tim.