LA.pm: Re: Prepend

Arkadiy Sudarikov asudarikov at xceed.com
Fri Oct 5 14:39:27 CDT 2001


Here is what I am going to do:

my $sth=$dbh->prepare(q(...));
$sth->execute($foo, $bar, $baz);

my $records=0;
while ($sth->fetchrow) {
 ++$records }

print FILE $records, "\n";

$sth->execute($foo, $bar, $baz);

while (my $hashref=$sth->fetchrow_hashref) {
 print FILE $hashref->{'Data'}, "\n" }

$sth->finish;

It's prepared once, cached, and executed twice. First time to get the count,
second to format and output data.



More information about the Losangeles-pm mailing list