in reply to Re^2: Perl Oracle Database Connections remain ESTABLISHED!!
in thread Perl Oracle Database Connections remain ESTABLISHED!!

Your problem is that you've declared $dbh outside of your subroutine, but reference it inside your subroutine. You should pass it into the subroutine instead. Have a look at this mod_perl doco

(P.S. If you don't wnat to pass you database handle around, just connect and disconnect in the main trunk of your code)

  • Comment on Re^3: Perl Oracle Database Connections remain ESTABLISHED!!

Replies are listed 'Best First'.
Re^4: Perl Oracle Database Connections remain ESTABLISHED!!
by perrin (Chancellor) on Jan 03, 2006 at 14:38 UTC
    That would cause a scoping problem, but wouldn't prevent an actual disconnect() call from working.
      It's may not be just a scoping problem. Apache::Registry will cache the script inside a subroutine, similar to
      #!/usr/local/bin/perl -w use DBI; use strict; use diagnostics; sub emulate_sub { my $dbh; sub connect { $dbh = DBI->connect('dbi:Oracle:rdb1', 'scott', 'tiger') || die DBI::errstr; } }
      I suspect that there's there's a copy with a connection, but the diconnect is not available. UPDATE: I was updating the thread while perrin was replying. It probably won't affect what he says, as his answer still applies to the updated version
        Apache::Registry wraps it in a sub, but since $dbh is visible to both the connect and disconnect subs, it doesn't really matter. The $dbh variable will stay in scope, but the disconnect call will still work unless there is an actual bug in his code. The scoping seems to have been intentional.