Robert Brock Guest
|
Posted: Mon Aug 09, 2004 5:48 pm Post subject: Re: Lock record / D7 and SQL2000 |
|
|
SQL is a shift from desktop databases, they use Optimistic as opposed to
Pessimistic locking, in other words, most SQL applications expect to handle
the problem AFTER they try to save..
From the old BDE, this was represented with UpdateKind..
UpWhereAll - Update would succeed if NONE of the Columns listed were changed
since grabbed.
UpWhereChanged - Update would succeed if NONE of the CHANGED Columns were
changed..
UpWhereKeyOnly - Update would succeed as long as the primary key hadn't
changed..
After a failure, "Um, User A, another user beat you to it, so we have to
abandon your changes!"
You can use semaphore locks, ie, roll your own, by tracking who has what in
a table system that you construct and maintain..
The most reliable way to implement pessimistic locking is to update the row
FIRST with a dummy statement (set a value to itself), prior to edit state,
which effectively locks the row until next commit or rollback. This affects
concurrency, however, as with the user that opens an edit screen, and heads
off to a 3 hour lunch..
Rob
|
|