Jonathan Leffler wrote: > On 11/8/06, Bart Lateur <[EMAIL PROTECTED]> 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