Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Relational Databases
Expertise: Beginner
May 13, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Record locking (Delphi 2 Paradox 5)

We are trying to write a multi-user Delphi 2.0 app (with Paradox 5.0 tables), and are looking for a way to determine if a record is locked by another machine before we attempt to modify it. I have tried to use the DbiIsRecordLocked function, to no avail. It always returns false, even if I have called DbiGetRecord or Table.Edit. The BDE knows it's locked because a subsequent call to DbiGetRecord or edit on that record raises an exception (Record locked by user: username). Is DbiIsRecordLocked supposed to work across a network (netware or NT), and if so, how is it used correctly?

This is one of the "problems" with the Paradox locking scheme. It's not enough to just be in Edit mode. In order to create a "locked" condition on a record, you have to physically change it in some way. One way I've gotten around this is to create a dummy field of a single byte that gets changed as soon as a user lands on a record. This puts the record into a locked state that can then be checked with DBIIsRecordLocked from other machines. It's not the prettiest technique, but it works.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date