On 04/25/12 14:21, Mike Copeland wrote:
> My understanding is that when you, for example, SEEK to locate the one
> record you want to UPDATE, then REPLACE (without ALL or FOR or WHILE)
> then it will lock only the record being updated.
Why are you guys wondering when/whether VFP will get a record lock?
Lock it yourself, when you want, and eliminate the doubt!
Here's a piece of code from one of my systems that deletes old invoices
for an account being deleted....
... at system startup ...
SET REPROCESS TO AUTOMATIC
.........
.........
do DB_SELECT with 'INVOICE'
set order to ACCT_NUM
seek Macct
scan while ACCT_NUM = Macct
if rlock()
delete
unlock
endif
endscan
--------------------------------
If I were updating, the REPLACE would be where the DELETE is.
And yes, it would be a single statement, because it is faster than
multiple ones. How do I know? I measured it, years ago.
Why do we use Automatic? From the Help file...
-------------------------
The "Attempting to lock ... Press Escape to Cancel" system message
appears while Visual FoxPro attempts to lock the record or file. The
lock is placed and the system message is cleared if the record or file
becomes available for locking while you wait. If a function is used to
place the lock, the function returns true (.T.).
If an ON ERROR routine is in effect and ESC is pressed, the ON ERROR
routine is executed. If a function attempts to place the lock, an ON
ERROR routine is not executed and the function returns false (.F.).
-----------------------
Since we have an Error Trapping function, the user sees the following:
If there's no conflict: nothing - it just works
If there's a conflict: Attempting to lock...Press Escape to Cancel"
until a) The other user unlocks, when it disappears
or b) This user presses Escape. Then the error trap executes.
In practice, we almost never see a conflict. If the server/network is
really, really slow the 'Attempting to lock' might pop up for a second
or so. If there's a real problem, the Error Log will tell us.
Dan
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.