View Single Post

  #2 (permalink)  
Old 11-05-2005
Lars
 
Posts: n/a
Default Re: Atomicity problem / question

> Make sure you have an auto-incrementing field. Insert an empty
> record, return the new incremented value to the user.
>
> Next user inserts next record, gets next key.
>
> Once they've completed their input, do an update to the empty record
> using he auto-incremented number.


Thanks for your reply.

Your method would probably work, but I was not totally clear in my original
post: I am looking for is a cleaner method. I would prefer not having to
have a separate table just for generating a unique value (or, rather, one
table for each type of unique value).

Something like this would work if I could lock the record:

UPDATE table SET field = field + 1 WHERE whatever
SELECT field from table WHERE whatever

Short of using a table lock or switching to InnoDB, what is the best way to
accomplish this?

Thanks,
Lars


Reply With Quote