Simply wrap your execute statement in an eval block and catch the error. (I'd say use Try::Tiny but it doesn't play nice with DBI, at least for me.)
By all means keep RaiseError => 1 and PrintError => 0 for this to work.eval { $sth->execute(); ... }; if ( $@ ) { # log the full error message write_log( $sth->errstr ); # and re-throw the common message die 'HEY!!!! Something is messed up here!'; }
EDIT:
On a side note, it is extremely poor practice (and bad security) to interpolate values directly into the SQL statement. Use placeholders instead and supply the values as params to the execute statement instead.
my $sql = q{INSERT INTO mytable VALUES ( ?,?,? )}; eval { $dbh->do( $sql, undef, ($val1, $val2, $val3) ); }; if ( $@ ) } # error trapping here ... }
In reply to Re: want to skip displaying of "DBD::Oracle::st execute failed:" error messages showing full query
by boftx
in thread want to skip displaying of "DBD::Oracle::st execute failed:" error messages showing full query
by sumalatha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |