Dear Monks,

I need some help with DBI:

My strategy is to use RaiseError=>1 and define a general die handler like this

use strict; use DBI; use Carp ('verbose'); ... my $dbh = DBI->connect( $dsn, $username, $password, $options ) or die "cannot connect to '$dsn'\n"; $dbh->{HandleError} = sub { warn $DBI::errstr; # how to display the last statement ?? Carp::confess }; ... my $insstm = "insert into mytable values ( ?, ? )"; my $inssth = $dbh->prepare( $insstm ); for ( 1..3 ) { $inssth->execute( myseq.nextval, $_ ); }
First the confess messages are somehow shortened like this:
main::__ANON__('DBD::Oracle::st execute failed: ORA-01722: UngM-|ltige Zahl (DBD E...', 'DBI::st=HASH(0x820cacc)', undef) called at insert-test.pl line 61
To facilitate debugging I need to see the actual statment executed. How can I achieve this?

Thanks very much for your time,
Axel.

In reply to DBI HandleError statement display by axelrose

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.