Solved

Foxpro for DOS 2.6 record locking

Posted on 2013-11-10
4
1,017 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 42

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
foxpro limit number of licenses 11 65
Toolbar in a formset deletion 1 308
Foxpro, Word 2003 Automation and Windows 7 10 920
filtering a list vfp 4 170
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…
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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