in reply to want to skip displaying of "DBD::Oracle::st execute failed:" error messages showing full query
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 ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: want to skip displaying of "DBD::Oracle::st execute failed:" error messages showing full query; Try::Tiny
by Anonymous Monk on Apr 07, 2015 at 21:39 UTC | |
by boftx (Deacon) on Apr 07, 2015 at 22:02 UTC | |
by sumalatha (Novice) on Apr 10, 2015 at 07:14 UTC |