on Mon, 08 Apr 2002 20:29:07 GMT, Daniel Rozengurtel wrote:
> Hello All,
>
> i am trying to select a big chunk of data to archive it into a flat
> file. Its a " select * " query which normally returns 1,200,000
> records.
> 1. Is there anything in DBI/DBD that I can use to do the job
> without selecting first and then storing it?
For large numbers of records, you can use the following:
$sth = $dbh->prepare("SELECT * ...");
$sth->execute();
open (OUTFILE, ">$tfm") or die;
while (my @record = $sth->fetchrow_array) {
print OUTFILE join("|", @record) . "\n";
}
$sth->finish();
close(OUTFILE);
without the need to have all the records in memory at the same time.
But perhaps it's better to use one of the tools that come with your
database software to do this kind of dumps. Usually these are much
faster. What database are you using?
--
felix