Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RLOCK() Problem

Status
Not open for further replies.

hawkieboy

Programmer
Apr 30, 2002
49
GB
Hi

I have a multi-user application that is stored on a server the application has an edit notes fuction which when pressed performs RLOCK() which if the record is locked gives the message 'someone is editing this person' the record is then unlocked when the user clicks save.

The problem i am having is when a user clicks the edit button they get the message, however they are sure that the no other users are editing the person. so i tried to mimic what they were explaining but the record always unlocked i even tried crashing the application but this still unlocked the record.

Please could someone explain to me what happens when a record is locked i.e. what kind of information is stored in the database.

also is there a way that i could unlock all records in a multi-user environment without everyone having to exit the application

Nick your help and advice is appreciated
 
Hi

Read the help on
SET MULTILOCKS ON/OFF
SET REPROCESS TO
These commands should be read by you and used suitably.

IF RLOCK()
** I am here because I am able to LOCK
ELSE
** I am here because I am unable to lock
ENDIF

By default, RLOCK( ) makes one attempt to lock a record. Use SET REPROCESS to automatically retry a record lock when the first attempt fails. SET REPROCESS controls the number of lock attempts or the length of time lock attempts are made when the initial lock attempt is unsuccessful. Now.. depending on this setup.. ELSE statement could fire or not fire. RLOCK() does not guarantee that a record is locked, but can be made to wait till the lock is successful.

The key to your problem is setting the REPROCESS command.
Make sure SET EXCLUSIVE OFF is also run.
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
** current lock code
set reprocess to 1
if rlock() = .f.
messageb("someone is updating this record")
return
endif
** current unlock code
unlock in alias

my problem is that some freak occurences have meant that a user has not unlocked a record but has got out of the application ie. closed the data environment. I am having trouble clearing these locks.

I know this shouldn't happen but apperently it is and I wondered if anyone else has ever come across similar things.

Thanks

Nick your help and advice is appreciated
 
As far as I know, records do not "stay locked" when users "get out" of an application.

And also, you cannot UNLOCK a record which you did not LOCK.

You are looking in the wrong place for this problem you are having. I would take a fresh look at why records are appearing locked. It is probably because they are presently being used by someone.


Don
dond@csrinc.com

 
Is this in a LAN or client-server environment? If so and the server OS is NT or Widnows 2000, there might be a problem with Opportunistic Locking. See Microsotf's web site for articles on this and how to disable it at the server and the client.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top