From: Deviloper <[EMAIL PROTECTED]>
> in the early days of the dbi-modul there was a function $dbh->ping().
> nearly no driver ever implemented it.
>
> I want to check the status of my db, in my daemon on a regular base.
> I could not find any standard solution. Today I´m just doing a query
> and check then if there where errors.
>
>
> Also I want to reread the DB config.
> (My Daemons are running stable for years, but the DB-Guy switch from one db
> to another
> on a weekly base and I just wont care if my configfile is reread.)
>
>
> I do it this way :(RaiseErrors is off)
>
> my $sth = $dbh->prepare("$query");
my $sth = $dbh->prepare($query);
Do not quote variables! It's pointless. It just forces Perl to make a
copy or even convert a number to a string. And if the variable
happens to be a reference you end up with a string that kinda looks
like a ref, but isn't.
> $sth->execute();
>
> # $sth->finish(); #not needed with autocommit
from perldoc DBI:
The finish method does not affect the transaction status of the
database connection. It has nothing to do with transactions. It's
mostly an internal "housekeeping" method that is rarely needed.
> if ( defined $DBI::errstr || defined $sth->errstr()){
> # close db.
> #... reread configurationfile and
> # connect with new config.
> }
I generaly prefer to use RaiseError.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/