|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Disconnecting from the server
Date: Mar 31 2003 4:02PM
On Mon, 2003-03-31 at 06:22, Sabherwal, Balvinder (MBS) wrote:
> How do I disconnect and connect in a loop at set interval. ct_disconnect or
> $dbh->disconnect doesn't works.
The connection is dropped when the $dbh goes out of scope (or gets
"undefined").
For example:
sub run_it {
my $dbh = new Sybase::CTlib ...;
... do stuff ...
}
Because $dbh is declared in the subroutine it goes out of scope at the
end of the subroutine, so when run_it() returns the connection is
closed.
You can also close a connection by doing
$dbh = undef;
Note however that opening and closing connections in a loop causes a
memory leak, so be prepared for your process to grow...
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
|