use strict; use warnings; use DESD::DBI_Utils qw(open_db_connection); $|++; use constant DATABASE => 'SOMEDB'; print "Establishing connection to DB ".DATABASE()."\n"; my $dbh = open_db_connection( 'me', 'password', server => 'MYSERVER', database => DATABASE ); for my $raiserror (0,1) { for my $printerror (0,1) { $dbh->{RaiseError}=$raiserror; $dbh->{PrintError}=$printerror; for my $val qw(1 null) { eval { print "RaiseError=$raiserror PrintError=$printerror Value=$val\n"; my $sth=$dbh->prepare("exec check_error_return \@throw=$val") or die "MYERROR: Can't prepare statement: $DBI::errstr"; my $rc = $sth->execute() or die "MYERROR: Can't execute statement: $DBI::errstr"; print "Got:"; my $ret; while (($ret) = $sth->fetchrow_array) { print "$ret\t"; } print "\n"; # check for problems which may have terminated the fetch early die "MYERROR:".$sth->errstr if $sth->err; }; if ($@) { if ($@=~/MYERROR/) { print "Got an inline error:\n$@"; } else { print "Got an exception:\n$@"; } } else { print "No error\n"; } } } }