From the DBI pod under "METHODS COMMON TO ALL HANDLES" for "err:

"The DBI resets $h->err to undef before almost all DBI method calls, so the value only has a short lifespan. Also, for most drivers, the statement handles share the same error variable as the parent database handle, so calling a method on one handle may reset the error on the related handles."

Given the "most drivers" above I presume some drivers don't share the error variable for database and statement handles. Which are these drivers? If you don't know of any, perhaps you can tell me how to find out whether they do? I did find the following in DBI.pm:

sub _new_drh {  # called by DBD::<drivername>::driver()
    my ($class, $initial_attr, $imp_data) = @_;
    # Provide default storage for State,Err and Errstr.
    # Note that these are shared by all child handles by default! XXX
    # State must be undef to get automatic faking in DBI::var::FETCH
    my ($h_state_store, $h_err_store, $h_errstr_store) = (undef, 0, '');

The reason I'd like to know is that I have some circumstances where an error occurs on a statement handle which goes out of scope immediately so err is not available. I notice the connection handle (with DBD::Oracle) also contains the same error number/string and this would be great except for the fact we use multiple DBDs.

Thanks.

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Reply via email to