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"); }
In reply to capture sybase error by mnlight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |