there is a LIMIT option for the SELECT statement that will return the number of records you desire.
$sth = $dbh->prepare("select <whatever> from <table> <optional WHERE arguments> LIMIT <desired number of records>"); $sth->execute(); while ($vars ...) = $sth->fetchrow_array()) { } # or whatever syntax best suits your preferences On Thu, Sep 11, 2008 at 6:53 AM, Amit Saxena <[EMAIL PROTECTED]> wrote: > Hi all, > > I am looking for a "fetch" function to fetch "n" number of records at a time > in Perl DBI ! > > "fetchrow_hashref" fetches one row at a time whereas "fetchall_hashref" > fetches all the rows at a time. > > The requirement is to get 100 records at a time (in array or hash) before > printing it into the output file. > > I don't want to use following style ;- > > my $count=0; > while ($href1 = $sth->fetchrow_hashref()) > { > my @arr1 = (); > $count = $count + 1; > %arr1 = %$href1; > if ($count == 100) > { > # print to the output file > print PTR %arr1; > } > } > > Thanks & Regards, > Amit Saxena > -- since this is a gmail account, please verify the mailing list is included in the reply to addresses -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/