Actually I have executed the postgres query, assume that it has return the 10 rows. Now I am having that’s statement handler ( $sth ) .
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
Now , I have fetched the 5 rows from the statement handler ( $sth .Now I want to get back
$sth reference pointer to 1th row…..
What should I do….?
Thanks
You cannot do that. Database cursors are designed to be read row by row, like a stream, without rewinding.
You need to copy the data into an array in memory if you want to jump around.
The easiest way would be to do
which gives you an arrayref, with one entry for each row, each row in the same format as
fetchrow_arrayrefproduced.