Subject: | private_* undef with execute ? |
Hi,
I'm using DBI 1.609 and perl v5.10.1 on Linux 2.6.35-25-generic
#44~lucid1-Ubuntu SMP Tue Jan 25 19:17:25 UTC 2011 x86_64 GNU/Linux
I wrote a custom function to handle errors, and I store values in a
private attribute ("private_mymodule_value")
When a dbh->do(...) throws an error, I can access to my private value in
my handle_error function.
But when $sth->execute throws an error, my private value is undef.
An example :
"
#! /usr/bin/perl -w
use strict;
use DBI;
my $dbm_str = 'DBI:mysql:xxxx';
my $dbm_login = 'xxxx';
my $dbm_pass = 'xxxx';
my $dbh = DBI->connect($dbm_str, $dbm_login, $dbm_pass, { RaiseError =>
1, PrintError => 0 }) || die;
$dbh->{private_mymodule_value} = '42';
$dbh->{HandleError} = \&handle_error;
#$dbh->do('bad request');
my $sth = $dbh->prepare('bad_request');
$sth->execute;
sub handle_error {
my ($error, $db_handle, $str) = @_;
print "Entering custom handle_error_function\n";
print 'Value = [' . $db_handle->{private_mymodule_value} . "]\n" ;
}
"
The output is :
"
Entering custom handle_error_function
Use of uninitialized value in concatenation (.) or string at
./test_dbi.pl line 26.
Value = []
"
With dbh->do("bad_request"), the output is:
"
Entering custom handle_error_function
Value = [42]
"
Am I doing something wrong ?