Solved

Foxpro for DOS 2.6 record locking

Posted on 2013-11-10
4
967 Views
Last Modified: 2013-11-12
I have been asked about record and file locking in Foxpro for DOS 2.6. What would be the best way to approach record locking for record writes/updates? What about file locking?
0
Comment
Question by:Idarac
4 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39637276
It's like asking what is the best way to use a kitchen.

The topic locking is a bit narrower, still if you ask this question without telling what you expect of locking and how your application should work, you better first read about what locking can do for.

First of all locks are only needed for multi user environments. Is your dos app multi user at all?

Bye, Olaf.
0
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 39637284
Several concepts exist:

1) Do nothing and FoxPro will lock records/files automatically. You just need to process possible error messages when the lock fails.

2) Explicit file/record locking by FLOCK()  or  RLOCK() - lock the record if you are updating it, lock the file if you are updating more records. You may split this approach into two parts:

a) pessimistic locking - lock the record/file before you start editing it
b) optimistic locking -  lock the record/file just before you save your changes to it

Pessimistic locking can block your application if several users are updating same record/file. Optimistic locking is also called "The last is the winner" - changes made by the last user saving data into a file/record represent the final record/file contents.

I am using record locking for header table and automatic locking for line tables obviously. (I suppose if the Order/Invoice header is locked by me then nobody else will write to appropriate order/invoice lines.)

To have your application running smoothly the record and namely the file should remain locked as short time as possible. Never leave the record/file locked when you are waiting for user response. If this is necessary then all READ commands should have timeout activated to avoid application blocking.

You should study following commands/functions in the FoxPro help:
RLOCK(), FLOCK(), UNLOCK, SET EXCLUSIVE, SET REPROCESS, SET REFRESH, FLUSH
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 39637830
The usual approach to locking a single record:

IF RLOCK('table')
    DO stuff
    UNLOCK IN table
ELSE
    WAIT WINDOW "Record is locked by another user".
ENDIF

Open in new window

0
 
LVL 1

Author Closing Comment

by:Idarac
ID: 39641764
Great answer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Foxpro executable does not show up 3 454
Alter Cursor Results 4 142
FoxPro Visual Studio 2013 10 998
Foxpro 2.6 for windows compatiblity on 64 bit Windows OS 2 137
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now