RE: Retrying a fetch after an error, without restarting the whole loop?
- From: Philip.Garrett@xxxxxxxxxxx (Philip Garrett)
- Date: Thu, 9 Nov 2006 09:43:03 -0500
Jonathan Leffler wrote:
On 11/8/06, Bart Lateur <bart.lateur@xxxxxxxxxx> wrote:[snip]
1) What's the best way to temporarily disable RaiseError when I want
to have it enabled for the rest of the script? Say, for one SQL
statement?
$sth->{RaiseError} = 0;
Or:
$dbh->{RaiseError} = 0;
$dbh->do("something that might fail");
$dbh->{RaiseError} = 1;
In situations where I want RaiseError (or AutoCommit, or whatever) to be
reset once a certain piece is done, I use the "local" keyword.
This ensures that:
1) The flag always gets reset, even if something in that code
block dies, and
2) The value is always what it used to be, without you having to save
the old value in a temp variable.
# e.g.
{
local $dbh->{RaiseError} = 0;
$dbh->do("something that might fail");
$obj->operation(); # this dies, but RaiseError is still reset
}
Regards,
Philip
.
- Prev by Date: Re: DBD::ADO and Access IMAGE (OLE Object) fields...
- Next by Date: Bugs in the Module::Dependency
- Previous by thread: Re: Retrying a fetch after an error, without restarting the whole loop?
- Next by thread: DBD Sybase make test errors
- Index(es):