On 2005-08-12 14:36:02 -0400, Owen wrote:
On Wed, 10 Aug 2005 21:35:31 +0200
Peter J. Holzer [EMAIL PROTECTED] wrote:
the next line causes an exception, but shouldn't:
$tkcount = $dbh-selectrow_array($sth, {}, 'baz');
print $tkcount\n;
Yes, I get the same error message when s/baz/bar/ but not s/baz/foo/
Oops. Seems I wasn't quite awake when I tested that. I always get the
error at the second selectrow_array, regardless of whether I'm searching
for foo, bar or baz.
If I prepare a new statement handle, all three cases work as expected.
So the issue doesn't seem to be whether the query returns any rows, but
passing a statement handle to multiple selectrow_array calls.
OTOH, reusing the statement handle with execute and fetchrow_array works
fine:
my $sth = $dbh-prepare(select count from tokens where token=?);
my $tkcount;
$sth-execute('foo');
while (($tkcount) = $sth-fetchrow_array) {
print $tkcount\n;
}
$sth-execute('bar');
while (($tkcount) = $sth-fetchrow_array) {
print $tkcount\n;
}
$sth-execute('baz');
while (($tkcount) = $sth-fetchrow_array) {
print $tkcount\n;
}
$dbh-disconnect;
hp
--
_ | Peter J. Holzer| In our modern say,learn,know in a day
|_|_) | Sysadmin WSR | world, perhaps being an expert is an
| | | [EMAIL PROTECTED] | outdated concept.
__/ | http://www.hjp.at/ |-- Catharine Drozdowski on dbi-users.
pgpL4H24NzoJ8.pgp
Description: PGP signature