axelrose has asked for the wisdom of the Perl Monks concerning the following question:
I need some help with DBI:
My strategy is to use RaiseError=>1 and define a general die handler like this
First the confess messages are somehow shortened 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, $_ ); }
To facilitate debugging I need to see the actual statment executed. How can I achieve 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI HandleError statement display
by tommyw (Hermit) on Aug 07, 2002 at 09:58 UTC | |
by axelrose (Scribe) on Aug 07, 2002 at 10:58 UTC | |
by hmerrill (Friar) on Aug 07, 2002 at 13:41 UTC | |
by axelrose (Scribe) on Aug 07, 2002 at 13:56 UTC | |
by Anonymous Monk on Aug 07, 2002 at 20:05 UTC | |
|
Re: DBI HandleError statement display
by axelrose (Scribe) on Aug 09, 2002 at 09:03 UTC |