If the error is on the first fetchrow_hashref, there is not enough code to see
what the problem is. If it is the second fetchrow_hashref, finish should be
called after the while, if at all. If your while loop fetches all of the rows
and
fetches again to get the undef value which indicates no more
data, then you do not need it at all. An excerpt from perldoc DBI:
"finish"
$rc = $sth->finish;
Indicates that no more data will be fetched from this
statement handle before it is either executed again or
destroyed. The "finish" method is rarely needed, but
can sometimes be helpful in very specific situations to
allow the server to free up resources (such as sort
buffers).
When all the data has been fetched from a "SELECT"
statement, the driver should automatically call "finish"
for you. So you should not normally need to call it
explicitly except when you know that you've not fetched
all the data from a statement handle. The most common
example is when you only want to fetch one row, but in
that case the "selectrow_*" methods may be better
anyway. Adding calls to "finish" after each fetch loop
is a common mistake, don't do it, it can mask genuine
problems like uncaught fetch errors.
"NIPP, SCOTT V (SBCSI)" wrote:
> I keep coming up with this error, but I AM performing an execute
> prior to the fetch. I have seen some other threads on this, and have
> upgraded the DBD:Mysql to the latest version on CPAN. Any ideas? Here is a
> small portion of the code:
>
> if ($rows2 == 1) {
> my $vals = $test2->fetchrow_hashref ('NAME_lc');
> my $id = $vals->{id};
> my $query = $dbh2->prepare("SELECT * FROM fsdata WHERE id ='$id'");
> $query->execute();
> $query->finish();
> while (my $ref2 = $query->fetchrow_hashref ('NAME_lc')) {
> undef $set2;
>
> I am getting an error on the fetchrow_hashref line. Thanks in
> advance.
>
> Scott Nipp
> Phone: (214) 858-1289
> E-mail: [EMAIL PROTECTED]
> Web: http:\\ldsa.sbcld.sbc.com
--
James D. White ([EMAIL PROTECTED])
Department of Chemistry and Biochemistry
University of Oklahoma
620 Parrington Oval, Room 313
Norman, OK 73019-3051
Phone: (405) 325-4912, FAX: (405) 325-7762