[Omaha.pm] DBI /(Raise|Print)Error/ trick...

Jay Hannah jhannah at omnihotels.com
Wed Jan 19 08:01:10 PST 2005


Interesting. I don't think I've used this trick before.

My program has DBI's RaiseError and PrintError on globally, but for this one SQL statement I really don't care if it works or not. (If it fails it'll work next time. No biggie.)

This is suggested in "perldoc DBI"...

  {
    local ($dbh->{RaiseError}, $dbh->{PrintError});
    $dbh->do("delete from $test where property_id = 'TEST'");
  }

I never use local, but here it seems pretty handy. { } is a new block, and local sets up a copy of those variables just for the scope of my { }. As soon as it exists that block, those variables go back to whatever they were before.

Pretty neat, huh?

j






More information about the Omaha-pm mailing list