... my $sth = $dbh->prepare($StoredProcedureSQL); if(!$sth->execute(@args)) { print "Met with error: ", $sth->errstr, "\n"; # exit / die / croak / return / next / last } while ( my $row = $sth->fetchrow_arrayref ) { ... } ...