eval { # # Prepare the SQL Statment # my $sth = $dbh->prepare($sql) or die "Can't prepare SQL statement: $DBI::errstr"; # # Execute the SQL Statment # my $rc = $sth->execute(@values) or die "Can't execute SQL statement: $DBI::errstr"; # # Fetch the result # $data = $sth->fetchall_arrayref({}); $sth->finish; # # check for problems which may have terminated the fetch early # die "Can't query result: $sth->errstr" if $sth->err; }; if ($@) { print STDERR "ERROR [query_database()]: $@"; return 0; }