RE: Surprising DBD::Oracle error raised

John Scoles <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
Well isn't he is calling with the alias 'fetch' and he is calling it in I think scalar context

 

 

my ($row) = $s->fetchrow_array;


vs

 

 if ($price_sth->fetch) 


There is the odd chance that he is doing the SQL against a 'view', 'cursor'   or alike but I doupt that is it.

 

 

> Date: Wed, 5 Feb 2014 13:25:03 +0000
> From: [email protected]
> To: [email protected]; [email protected]
> Subject: Re: Surprising DBD::Oracle error raised
> 
> On 04/02/14 19:36, David Nicol wrote:
> > $price_sth->execute;
> > my ($o_file_price) = $price_sth->fetchrow_array();
> > if ($price_sth->fetch) {
> > $this->log_error('ERROR: scalar select returned second row at
> > %s line %d', __FILE__, __LINE__);
> > }
> >
> >
> > I expected the fetch to return undef, but it throws an Oracle error.
> > My best ignorant guess here is that fetchrow_array does some cleanup
> > on one-row datasets, but that isn't documented.
> >
> > Advise?
> >
> >
> 
> That is in deed interesting. When I run the following with DBD::ODBC to MS SQL Server:
> 
> use strict;
> use warnings;
> use DBI;
> 
> my $h = DBI->connect();
> eval {
> $h->do(q/drop table mje/);
> };
> 
> $h->do(q/create table mje (a int)/);
> my $s = $h->prepare(q/insert into mje values(?)/);
> $s->execute(1);
> $s->execute(2);
> 
> $s = $h->prepare(q/select * from mje where a = 1/);
> $s->execute;
> my ($row) = $s->fetchrow_array;
> print "$row\n";
> $row = $s->fetch;
> print "$row\n";
> 
> 
> I get:
> 
> 1
> Use of uninitialized value $row in concatenation (.) or string at mje/fetch_off_end.pl line 20.
> 
> However, I get the same with DBD::Oracle so how is you code different from the above.
> 
> Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.