Instead of fetching again, setup a hash of hashes and populate it on the
first fetch... then it's right there for you the second time
around... depending on the amount of data and how many times you need to
use the same data set, it could save you more time than reexecuting and
refetching.
--Curt
On Mon, 14 May 2001, [iso-8859-1] Jonas Askås wrote:
> Hi,
>
> Sorry to bother you with an (maybe) easy question, but I don't now how to
> do...
>
> I want to to this:
>
> $SQL = "SELECT * FROM members";
> my $sth = $dbh->prepare($SQL);
> $sth->execute;
> my $record_hash;
>
> while ($record_hash = $sth->fetchrow_hashref){
> print "$record_hash->{first_name} $record_hash->{last_name}\n";
> }
>
> Then I want to search the "$sth" again, and maybe print some other
> information, like this:
>
> while ($record_hash = $sth->fetchrow_hashref){
> print "$record_hash->{last_name} $record_hash->{company}
> $record_hash->{e-mail}\n";
> }
>
>
> My question is:
> After I've search $sth the first time using the fetchrow_hashref-method, how
> do I point $sth to the first position in the array again, so I can serach it
> again?
>
> Regards,
> Jonas Askås
>
>