Matteo Beccati <php@beccati.com> writes:
> I added the error check with a second UPDATE try after INSERT to increase
> accuracy. In fact, INSERTs were sometimes failing because of concurrency, and
> this was the only viable solution I found to avoid losing data.
in the general case you could have someone else delete the record again before
you get the chance to update it again. to handle this case you would actually
have to make it a loop.
this is the main reason a built-in merge command could be nice, it would avoid
the need to loop, since it can take the lock on the existing record if it's
there or perform the insert if not.
--
greg