Re: finishing sth using Childhandles



Thanks, Tim.
One more question to the group:
If I "undef $dbh" when it is active and it has active (or inactive) child handles, what happens exactly?
Is an actual $dbh->disconnect() made, and are the $sth's finished at all? Is it DBD dependent?

Thanks in advance,
Henri.

On Aug 28, 2006, at 11:15 PM, Tim Bunce wrote:

On Thu, Aug 24, 2006 at 09:47:56AM +0200, Henri Asseily wrote:
Is the below the correct usage for finishing still active child
handles of a dbh?


foreach my $childh (@{$dbh->{ChildHandles}}) {
$childh->finish() if ($childh->{Type} eq 'st');
}

The children of a dbh will always be sth, but the test is harmless.

I'm getting an error when running the above code:

dbih_setup_fbav: invalid number of fields: -1, NUM_OF_FIELDS attribute probably not set right

Looks like a bug (in the driver, I'd guess, but you don't say which)
because calling finish should never need to call dbih_setup_fbav.

But checking for Active will probably avoid the problem:

$_->finish for grep { $_->{Active} } @{$dbh->{ChildHandles}};

Tim.

.



Relevant Pages

  • Re: finishing sth using Childhandles
    ... undef $dbh; ... <- DESTROY= undef ... and then calls the DESTROY for the dbh. ... Toute utilisation de ce ...
    (perl.dbi.users)
  • Re: InactiveDestroy with Class::DBI
    ... >>> $dbh hash change inside of the child process and the parent hash stay ... >> The undef probably does the damage - the connect again would be ... Setting the parent's $dbh ...
    (perl.dbi.users)
  • Re: InactiveDestroy with Class::DBI
    ... Aren't I avoiding using the same handle by doing a $dbh = undef in the child and then calling connect again? ... The undef probably does the damage - the connect again would be correct. ... handle to undef or replacing it with another should both cause the client to process to disconnect under normal circumstances since it will go out of scope and Perl will call DESTROY on the object at that time. ... However, by setting $dbh->{InactiveDestroy} = 1 on the parent inside the child, should avoid implicitly calling DESTROY when the $dbh goes out of scope for any reason. ...
    (perl.dbi.users)
  • RE: Autmatic function creation
    ... : DBH => undef, ... foreach (qq(DBH Q Handler)) { ...
    (perl.beginners)
  • How to call DBD::Oracles dbms_output_get from within a DBIx
    ... which is usually (from applications) called like this: ... As I'm in st::execute I have a $sth and can get hold of a $dbh. ... $sth->execute or return undef; ...
    (perl.dbi.users)