This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: Re: Bug in DBD::mysql? From: Ed Wang <ed.wang@homepagecorp.com> Date: Thu, 21 Sep 2000 11:14:41 -0700 Roger Grayson wrote: > > Ed Wang wrote: > > > > I'm not sure if this is a bug or not, but here goes. I'm using the > > MySQL driver 1.2209 & DBI 1.13. > > > > If I execute the following code snippet, everthing works as expected - > > it prints 'Account_Name'. > > > > my $sth = $dbh->prepare('SELECT Account_Name FROM Account WHERE > > Acct_ID = 92'); > > $sth->execute(); > > print $sth->{NAME}->[0], "\n"; > > > > However, if I execute the following code snippet, I get an error. > > > > my $sth = $dbh->prepare('SELECT Account_Name FROM Account WHERE > > Acct_ID = 92'); > > $sth->execute(); > > $sth->fetchall_arrayref(); # This line seems to undef NAME > > print $sth->{NAME}->[0], "\n"; > > Can't set DBI::st=HASH(0x80ec7e0)->{NAME}: unrecognised attribute. > > > > But if I change fetchall to fetchrow, everthing works again. > > > > my $sth = $dbh->prepare('SELECT Account_Name FROM Account WHERE > > Acct_ID = 92'); > > $sth->execute(); > > $sth->fetchrow_arrayref(); # This line does NOT undef NAME > > print $sth->{NAME}->[0], "\n"; > > > > In fact, only fetchall_arrayref() seems to undef NAME. > > > > This appears to be a bug. Has anyone seen this before? > > - Ed Wang > > > > -- > > Software Engineer > > ed@homepagecorp.com > > HomePage.com > > > Put your 'print $sth->{NAME}->[0], "\n";' statement between your > execute() call and your fetchall_arrayref() call and this will work. > > It is not a bug, fetchall_arrayref() retrieves the entire result set and > automatically does a finish on the statement handle. > > Roger > Software Dev > Motorola Thanks, yea I was already using that work-around. I just wanted to point out what might be a bug. I didn't mention it in my original post, but the code worked perfectly when I was using it againt both Oracle and Informix. When I switched to MySQL it acted differently. - Ed Wang ===