in reply to Re: Re: Re: mySQL with Perl
in thread mySQL with Perl
The exists clause is standard SQL, at least SQL-92, so it should be supported by most if not all platforms. Note that "supported" doesn't equate to "works well".
There are several ways to achieve concurrency control, and what I showed is not necessarily the best way (granted that "best" varies from circumstance to circumstance). You could also use user-defined transactions, though I think not every MySQL back-end supports those. Or you could define a unique key on the user name, and catch the error if you try to insert a duplicate. I said "Be careful" to the code you showed mainly because it was leaving a pretty wide window where someone could get a row in between the test and the insert.
|
|---|