Locking question.... 
Author Message
 Locking question....

Quote:

>Does anyone know if when a TTable tries to lock a record for writing and
>the entry is already locked (i.e. by another user over a network) it
>tries a couple of times, or waits for a few seconds before trying to gain
>the lock again?  Or, does it just raise an EDatabaseerror exception (I
>know this happens if the record remains locked...).

The Borland Database Eengine (BDE) uses an optimistic locking scheme. Under
this scheme, a record is not exclusively locked for the duration of the
time a user has an optimistic lock on the record. Instead, the BDE allows
the locked record to be updated by another user, but when the application
that placed the lock (Delphi) attempts to update the record, the BDE
notifies the application that the record has changed. The application then
has the option of inspecting the new record and deciding whether to submit
its changes or not. As soon as the application attempts to update the
table, a write lock is placed which is, for the duration of the update,
exclusive.

Optimistic locking avoids the performance and concurrency penalties
incurred by a lock that ties up record access for the duration of the time
that it takes to complete a single user's modifications.

Persistent record locks, ala dBASE or Paradox, are not used in Delphi.
Within the context of the above, a record lock remains only until the
record pointer moves to a new record or the data set is closed. When the
record pointer is moved to a new record, the lock on the old record is
released automatically and a lock placed on the new record (subject to
other factors such as the setting of the AutoEdit property of the
TDataSource component).

You can, if desired, create persistent record locks on one or multiple
records using direct calls to BDE API functions. Functions such as
DbiGetNextRecord and DbiGetPriorRecord can create such a lock, a parameter
of these function specifying the type of lock: none, read, and write. The
DbiRelRecordLock is used to release persistent record locks.
DbiIsTableLocked is used to determine whether the current record is locked.

**************************************************************************
Steve Koterski
Local InterBase Server Technical Support
Borland International, Inc.



Mon, 16 Mar 1998 03:00:00 GMT  
 Locking question....

Quote:

>Persistent record locks, ala dBASE or Paradox, are not used in Delphi.
>Within the context of the above, a record lock remains only until the
>record pointer moves to a new record or the data set is closed. When the
>record pointer is moved to a new record, the lock on the old record is
>released automatically and a lock placed on the new record (subject to
>other factors such as the setting of the AutoEdit property of the
>TDataSource component).
>You can, if desired, create persistent record locks on one or multiple
>records using direct calls to BDE API functions. Functions such as
>DbiGetNextRecord and DbiGetPriorRecord can create such a lock, a parameter
>of these function specifying the type of lock: none, read, and write. The
>DbiRelRecordLock is used to release persistent record locks.
>DbiIsTableLocked is used to determine whether the current record is locked.

Something worth noting here is that Paradox does use the BDE, and the
functionality is all there for Delphi to use, and when Steve says that
"persistent record locks .. are not used in Delphi," he simply means that this
is not how the current VCL-supplied objects were designed to do it...  not to
say that you could not easily change that behavior in several different ways.

For example, an event-procedure could apply and release the locks using
API-calls as noted.  

Or, if you wanted to do this all the time in your application, it is really
very easy to design your own descendent of TTable which includes that logic,
add it to your tools-menu as a component, and use it forevermore.  Thus you
have literally extended the behavior of what Borland gave you.  *This* is the
power of Delphi.

Borland consciously designed TTable to be as generic and upsizeable as they
could -- and this in some cases caused them to elect not to implement directly
certain features that BDE provides.  Although I would certainly like to see a
"TParadoxTable" component in a future product-release, what they decided to do
is certainly understandable and defensible.

/mr/



Tue, 17 Mar 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. multiuser file/record locking question

2. Record locking question

3. Paradox lock question

4. multiuser record/file locking question

5. ms-sql srv 6.0, delphi 1.0 locking question

6. A (dumb) question about locked records..

7. Newbie question: Record Lock

8. Optimistic Locking in Delphi: Question about

9. Locking/Locked records

10. turn off num lock, scroll lock

11. a traffic light program with lock's (num loack Caps loack and scroll lock)

12. help with record locking.. (Pessimistic locking)

 

 
Powered by phpBB® Forum Software