my $dbh = DBI->connect("dbi:Sybase:server=$percdb", $user, $passwd, {'RaiseError' => 1} ); if ($DBI::errstr) { FATAL($DBI::errstr); exit 1; } else { DEBUG('Successfully connected to database!'); } my $sth = $dbh->prepare($QUERY); $sth->execute; handle_db_error(); $result_hash = $sth->fetchall_hashref('ent_id'); handle_db_error(); sub handle_db_error { if ($dbh->err) { FATAL("Error: $DBI::errstr"); exit 9; } }