Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Checking mid program if connection still exists
Date: Dec 31 2002 4:50PM

On Wed, 2002-12-18 at 07:29, Stern, Meir wrote:
> Dear all,
> I sthere a way to check to see if te connection to the database is still
> available at the time I would like to use it meaning I can have the control
> handle because of the original; connection but it may be stale already. (I
> need to connect once on top but do not need to use the connection till way
> into the program wwhere it is in a loop) 

You can use $dbh->DBDEAD(). If this returns true then you need to
reconnect to the server. Note that the connection is only marked DEAD
*after* an attempt to use it fails, so it has to be checked not only
*before* using it, but also after using it if any of the calls fail.

Michael Peppler                              Data Migrations, Inc.       
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or 
long term contract positions -