in reply to Re: DBI HandleError statement display
in thread DBI HandleError statement display

Thanks for your reply, Tommy!

I tried "$dbh->{ShowErrorStatement} =1" as well as "$inssth->{ShowErrorStaement = 1" without any visible change in the error message.

The statement handles are indeed varying so I cannot use "$sth->Statement".

Some improvement though gives:
$dbh->{HandleError} = sub { warn $DBI::lasth->{Statement}; Carp::confess; }
Now the error messages looks like:
insert into mytable values ( ?, ? ) main::__ANON__('DBD::Oracle::st execute failed: ORA-01722: ...
I found a message from Tim Bunce in that he is planning an extension for showing the bound parameters as well. That means for the moment I'm stuck unless I give up the placeholders.

Replies are listed 'Best First'.
Re: Re: Re: DBI HandleError statement display
by hmerrill (Friar) on Aug 07, 2002 at 13:41 UTC
    Tommy, have you tried using $dbh->trace? Not sure what your application is doing, but if you're trying to insert invalid data, hopefully that means that you just haven't beefed up your edits enough yet. Use $dbh->trace to help figure out what "bad" data you're trying to insert, then beef up your edits to prevent that data from making it that far. I could swear that I've used Carp's cluck before and gotten a meaningful stack trace that *did* show the placeholder values trying to get inserted(or updated, whatever).


      Thanks for the hint. Yes, I found the culprit by using $dbh->trace(2).

      Nonetheless I wonder what the best *general* solution for reporting errors looks like.

Re: DBI HandleError statement display
by Anonymous Monk on Aug 07, 2002 at 20:05 UTC
    $dbh->{ShowErrorStatement}=1 before the prepare() should certainly work. Please double check and post a trace() extract to dbi-users if you can't fix it. Placeholder values will be shown if ShowErrorStatement is true _and_ the driver supports the new ParamValues attribute (few do yet). Tim.