
Jasmine
Administrator
/ Moderator
Jan 15, 2001, 3:57 PM
Post #2 of 5
(734 views)
|
|
Re: Maintaining the database connection
[In reply to]
|
Can't Post
|
|
If you have the program connecting when a query is made, it sounds like it may be a scoping issue. Without seeing the code, if you're using sub connect { my $dbh = DBI->connect('dbi:Oracle:'test','te1','te2') } Once connect finished the subroutine, $dbh has gone out of scope and the connection will terminate. If you return $dbh, however, it will stay alive: my $handle = connect(); my $searchresults = search($handle); sub connect { my $dbh = DBI->connect('dbi:Oracle:'test','te1','te2') return $dbh; } sub search { my $dbh = shift; my $query = $dbh->prepare("select statement here"); $query->execute() or die $dbh::errstr; # etc... } Hope this helps!
|