Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Who has the record locked?
Message
From
10/12/1997 09:33:46
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00064802
Message ID:
00064959
Views:
33
>>>>>I posted this question a week or two ago and got no answer (well... none that I liked anyway :-))
>>>>>
>>>>>Is there a way I can tell which record(s) in a table are locked without scanning the table and checking for locks on each individual record?
>>>>>Even better, is there some way to tell who (or what process) has it locked?
>>>>
>>>>I think if you want to check locks, you should really scan and check. You can built some mechanism to check who is 'lock holder', e.g. additional field which will be filled programmatically with oApp.userid anytime someone RLOCK() from application. Also, you can have some table (I call it 'locker.dbf') which check user name of 'form/process holders', if you want to provide one-user access to particular functionality.
>>>
>>>Thanks for the pointer, but my need is more of the troubleshooting type than the app design type. I considered an additional field in my main tables to hold who has the record locked, but at the time of app design, didn't deem it necessary. Scanning the table to check for locks just takes too long (125,000 records)... about 10-12 minutes. What would be cool is some sort of super secret internal index that keeps track of record locks... that's what I was hoping for.
>>>I guess the way that Fox knows if someone has a record locked is some sort of switch in the table header that doesn't hold the record, just whether or not there is a record locked.
>>
>>Ok another related question...
>>I thought that isrlocked() was supposed to return the lock status of a record... whether anybody has it locked.
>>I just did some testing.
>>
>>USEd the same table in VFP on both computers on my desk.
>>GO record# whatever (on both computers)
>>computer #1: RLOCK()
>>computer #1: ?ISRLOCKED() &&returns .T.
>>computer #2: ?ISRLOCKED() &&returns .F.
>>computer #2: ?RLOCK() &&returns .F.
>>
>>What gives? Am I misunderstanding the purpose of ISRLOCKED()? Is the only real way to see if a record is locked to try and lock it?
>
>No misunderstanding on your part. I ran into the same problem and now avoid the function altogether. Use IF RLOCK() instead. Related to your original question, you stated your need was more for administrative purposes instead of app purposes. What kind of admin are you talking about?

Not Admin, troubleshooting. Occasionally, some 'administrative' routines that need to lock the table cannot get a lock. As I have a _LOT_ of code out there operating on the tables in question, I can't figure out which user, (or routine) has which record locked.
The only reason I didn't want to use IF RLOCK() then UNLOCK is because of speed. RLOCK() takes about 6 times longer than ISRLOCKED(), but now it doesn't look like I have a choice.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform