Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Handling Null or Undef values in DBI (and things of those nature)...

by mpeppler (Vicar)
on Jan 08, 2002 at 05:26 UTC ( #137022=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://137022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-08-19 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?