I have Perl processes that update multiple dBs using Win32::ODBC than run 24/7. I ran into problems with some dB servers not being available because of maintence or other reasons. I wrote a package that connects to the dB(s) and stored the connection information. I have a sub that executes the query and if I get (Win32::ODBC::Error() =~ /Communication link failure/) after execution then another connection to the dB is made and the query executes again. It's something like this.
my ($rc) = $sql_obj->sql($query);
return ($sql_obj, undef) unless $rc;
return ($sql_obj, "".Win32::ODBC::Error()) unless (Win32::ODBC::Error
+() =~ /Communication link failure/);
my($sql_obj) = $self->connect($server, $user, $password);
return (undef, "Cannot reconnect") unless ($new_sql_obj);
$rc=$sql_obj->sql($query);
return ($sql_obj, "".$rc) if ($rc);
return ($sql_obj, undef);