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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best practice in locking records

Status
Not open for further replies.

TallGuyinIT

IS-IT--Management
Oct 18, 2004
34
US
Can someone help me with the best practice in locking a record while updating? I am trying to update an existing program that occasionally does not update the record. I have looked at other existing programs and the Microsoft knowledge base. There are several options. I am trying to determine which one is best practice, or is there even a better way.

Option 1 (existing code)
SET REPROCESS TO 0
SEEK (locate the record)
IF RLOCK()
*Code to update record
UNLOCK
ENDIF

Option 2 (other programs on our system)
SET REPROCESS TO 0
SEEK (locate the record)
DO WHILE RLOCK()
ENDDO
*Code to update record
UNLOCK

Option 3 (microsoft)
SET REPROCESS TO 0
SEEK (locate the record)
?RLOCK()
*Code to update record
UNLOCK

Any opinions or other options?
 

Surely, the answer depends on the extent to which users are prepared to wait for the lock, and the action you want to take if another process fails to release a lock in a reasonable time.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top