Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you lock a record fast?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00758830
Message ID:
00758902
Vues:
23
>I’m trying to locate the next available unlocked record in a table.
>The table has about 150 records in it.
>
>When I use following code it may take 30 seconds if the 31 record is next available unlocked record and rLock() will return .T. but it is slow

IsRLocked() will help, but it's not the complete solution.
Because it only tells you if YOUR workstation placed the lock not anyone else.

RLock()
Is the answer, but checking a lock isn't fast in all cases.
It depends on LAN/server performance.
It depends on SET REPROCESS whether it retries, and for how long or how many times.
If you're taking one second a record to test for locks, then what does ? SET("REPROCESS") give you?

I think that long-term locks on records aren't a good idea.
I prefer to use a field with a value that indicates the row is in use.
Lock briefly to update that value and then unlock.
Then you can find the next unused record in a select, or seek.
If you store the username to indicate it's in use by a particular person, then you can do something that you cannot achieve with record locking. Index on that field and you'll efficiently find recordsa that are/aren't in use.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform