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.)

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!'; }
By all means keep RaiseError => 1 and PrintError => 0 for this to work.

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 ... }

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.