Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Locking question
Message
De
18/06/2010 07:39:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/06/2010 07:23:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01469576
Message ID:
01469580
Vues:
67
>Hi,
>
>Codemine framework takes care of file and record locking so I am dusty on the subject and need help.
>
>A one record file holds several app variables including counters for lot number, transaction number, etc. The app normally uses table buffering across the board, including for that table. The routine that increases the counters has not been using file or record locking
>
>You can see what this leads to. Normally there have been only one or two users updating data, but now there are several larger sites and duplicate transaction and lot numbers have appeared.
>
>What is the best way to use locking to prevent duplicate generated numbers?
>
>Another question in the same case. As a precaution the routine that increases the counters doublechecks that the generated number is not already present in any of the tables that store it. This raises the question of how to know the value currently in the drive when a table is buffered. One way is using SQL SELECT without BUFFERING = .T. Is there another way?
>
>Thank you very much,
>
>Alex

Alex,
I think there is a sample called nextid?

The process is simple (and a more simplified version might look like this):
set reprocess to 1
declare void Sleep in win32API integer dwMillis
use theTable
* Try getting lock
do while !rlock() && if failed
   Sleep(10)   && delay a bit before retrying
enddo
replace lotNumber with lotNumber+1
local lnNewLot
lnNewLot = lotNumber
use
return m.lnNewLot
Other part I think is impossible to check when there are multiple users + buffering. You would try inserting with a primary or candidate index and if you get error, increase, retry.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform