in reply to Re^2: MSSQL and Perl - heavy load
in thread MSSQL and Perl - heavy load

Yes, as I read the docs, that should work fine (though it might be more informative to also print the $sth->errstr instead of simply doing exit 1).  As you're simply testing for truth, it does not matter whether ->err returns an integer or not (which doesn't seem to be guaranteed).

In general, when unconditionally reading/testing error variables or methods, it's good to check the docs, because in some cases, their value is invalid unless an error did in fact occur — think of $!. In this particular case though, this is not a problem, as the docs explicitly state "the DBI resets $h->err to undef before almost all DBI method calls" (the "almost all" refers to methods irrelevant here).

Replies are listed 'Best First'.
Re^4: MSSQL and Perl - heavy load
by taomanjay (Novice) on Jan 11, 2010 at 22:52 UTC
    Yes, I'll be logging the contents of $sth->errstr, and I'll also disconnect the db connection before exiting. Thanks almut, and everyone else who posted!