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

a silly question

Status
Not open for further replies.

Bertiethedog

Programmer
Feb 8, 2007
118
GB
I used to work in a bank & our file locking was done via a semaphore file.

On this site we are relying on foxpro table buffering CURSORSETPROP("Buffering",5)

What will happen if two people write back the same record.

Am I right to assume that the first Write back would be lost


Richard
 
VFP will accept the first change and report to the second person the record has been changed and they will have to reenter their change.

David W. Grewe Dave
 
Richard,

< Am I right to assume that the first Write back would be lost >>

It's not quite that simple.

You are presumably using TABLEUPDATE() to physically write the record. If you pass .T. as the second parameter to TABLEUPDATE(), the second update will overwrite the first.

If you pass .F. as the second parameter, TABLEUPDATE() will itself return .F. You can then use AERROR() to determine whether there is a multi-user collision, or some other reason for TABLEUPDATE() to fail. If it's a multi-user issue, you can decide what action to take. For example, you can check to see what edits the two users made, and perhaps try to combine them in some way, if that is a sensible thing for your application to do.

By the way, I disagree with the title of your thread. This is not at all a silly question. It is a fundamental issue, and you are quite right to raise it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
All the records are viewed via a form with a toolbar option to go into edit mode.

One of my options is to allow viewing but disable the edit button if anyone else has ownership of the record, as well as changing the buffering to record locking.

The other posibility is to use a semaphore file and use the buffer option so that I have a rollback if needed. The only problem I can forsee is with an insert or append as the master table would have to be updated.

Unfortunatly it is not a simple one table form I have 7 pages getting & sending information to at least 10 tables, there are at least 8 sub forms.




Richard


 
Richard,

One of my options is to allow viewing but disable the edit button if anyone else has ownership of the record

In that case, you should be using pessimistic locking. In other words, set the buffer mode to 4 rather than 5. That way, only one person will be able to edit the record at a time. That will solve the collission problem, but introduces new problems of its own.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top