in reply to DBI::fetchall_arrayref() error
Hello,
Although DBI docs clearly state that:The execute method does not return the number of rows that will be returned by the query (because most databases can't tell in advance), it simply returns a true value.this solution works for me, (MySQL 3.23.58, DBI 1.38, DBD::mysql 2.9003) without an ugly error:
... my $count = $sth->execute or die; my $total = 0; while (my $rows = $sth->fetchall_arrayref([0], 3)) { die "Error: $DBI::errstr" if $DBI::err; # error different # to 'end of while' for (@$rows) { print "got @$_\n"; } print "---\n"; $total += scalar @$rows; last if $total == $count; }
-sheep
update: Corrected logic errror I found in my thinking...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI::fetchall_arrayref() error
by pg (Canon) on Jan 12, 2004 at 02:27 UTC |