mnlight has asked for the wisdom of the Perl Monks concerning the following question:
Below is code that loads transaction files to a refreshed database. On occasion the files get out of sequence (Sybase ERROR 4305)and the script fails. I want this error to be captured break the foreach loop bring the database on line, leave the subroutine and then continue to the next step.
foreach my $tran_set ( @$trans ) { my $i = 0; foreach my $stripe ( @$tran_set ) { my $localfile = $stripe; $localfile =~ s(^.*/)($local_root); $stripe = $localfile; if ( $i == 0 ) { $sql = "load tran $db from \'$stripe\'\n"; } else { $sql .= "stripe on \'$stripe\'\n"; } $i++; } $$dbh->do($sql) or $app->log($FATAL, "Can't do sql statement [ $sql ]: $DBI::errst +r"); foreach my $stripe ( @$tran_set ) { rmtree($stripe); } } $sql = "online database $db"; $$dbh->do($sql) or $app->log($FATAL, "Can't do sql statement [ $sql ]: $DBI::errst +r"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: capture sybase error
by jfroebe (Parson) on Nov 23, 2005 at 19:14 UTC | |
|
Re: capture sybase error
by mpeppler (Vicar) on Nov 23, 2005 at 19:32 UTC |