in reply to Handling Null or Undef values in DBI (and things of those nature)...

For Q.2: In order to avoid race conditions (where you check fo r the record existence in the db, but someone else inserts it before you have a chance of inserting it) you should let the database do the checking.
This is normally done with a constraint (usually a unique index of some sort). You then trap that error in the insert logic. Something like this:
# Assumes RaiseError is set eval { $dbh->do("insert ...."); }; if($@) { # check for the "duplicate insert" error here, and # handle accordingly... }

Michael

  • Comment on Re: Handling Null or Undef values in DBI (and things of those nature)...
  • Download Code