Dear DBI list:

I need to iterate through a result set twice.  Right now I am running the 
query twice, but it is really slow.  Here is an example of what I am trying 
to do:

$sth=$dbh->prepare($sql);
$rv = $sth->execute || die "cant't execute the query: \n $sql \n: 
$sth->errstr";
$rv = $sth->rows;
while (@row = $sth->fetchrow_array) {
        Do something for each row;
        }
while (@row = $sth->fetchrow_array) {
        Do something else for each row;
        }

However, when I get to the second while loop, I can no longer use the 
fetchrow_array method.  Is there a way that I can copy the data set so that 
I can run through it again?

(if you are curious, the first run through lets me calculate some averages 
and create some scales for creating graphs, the second time through prints 
usage figures using the scale that was calculated the first time through).



Reply via email to