Reputation: 1141
I am about to implement a record locking mechanism as follows:
Table1:
Field: "ID" (AutoIncrement, Primary)
Field: "Name" (Text)
Field: "More fields..."
Table2:
Field: "ID" (Unique)
In order to lock a specific record in Table1, I'll create a record in Table2 with the same ID. If this creation fails due to such a record already existing, then the record must be locked by another process and I spin. If it succeeds, I have the lock and can modify the record. When I'm done, I delete the lock record in Table2.
My question is whether this is a valid way to implement a per-record lock, and if not, is there such a thing?
Cheers, Charlie.
Upvotes: 0
Views: 717