Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FLOCK() causes duplicate primary keys.
Message
From
26/08/2005 14:13:24
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01043971
Message ID:
01044394
Views:
18
>>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform