Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FLOCK() causes duplicate primary keys.
Message
De
26/08/2005 14:13:24
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Database:
Visual FoxPro
Divers
Thread ID:
01043971
Message ID:
01044394
Vues:
16
>>>>If you use semaphore (mutex?) then current values are not read to keys table.
>>>>So it is not possible to use some semaphore.
>>>
>>>Huh? I've been using semaphore files since dBaseIII to insure primary key validity.
>>
>>Why you don't use FLOCK() or RLOCK() ?
>>
>>Can you provide some sample code ?
>something like this:
>
>fhSemaphore = fopen("d:\path\file",12)
>if fhSemaphore > 0
>   nKey2Use = VAL( fread(fhSemaphore,128) ) + 1
>   insert into TARGET (field1,field2,fieldPK) values (cVar1, cVar2, nKey2Use)
>   nWrote = fwrite(fhSemaphore, str( nKey2Use ))
>   =fclose(fhSemaphore)
>else
>   =messagebox("File not available for appending",0,"Try again")
>endif
>
Thank you. Is is interesting idea to use FOPEN( , 12) instead of FLOCK()
I will try it if there is not any possibility to put FLOCK() to work.

Will this technique work OK under a heavy load by many concurrent users ?
Andrus
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform