"Ho, Tony" wrote:
> If the database goes down during the process of executing of the SELECT
> statements and writing to the file, what happens ?
Make sure that the RaiseError attribute is on for the DBI handle your working
on {RaiseError => 1}. Then execute the SELECT statemts within an eval{} block
to trap any errors. Test the exit status of $@ (see perldoc eval) to see if
there was an error retrieving the data - if no error write to file, something
like this:
open FH, ">$outfile" or die $!;
$sth->{RaiseError} = 1;
my $ary_ref;
eval {
$sth->execute();
$ary_ref = $sth->fetchall_arrayref;
};
if ($@) {
warn "Error reading data: $@";
}
else {
print FH @{$ary_ref}, "\n";
}
--
Simon Oliver