Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sequential numbers
Message
From
22/11/2002 11:45:32
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00725809
Message ID:
00725839
Views:
11
Thanks Nadya
Never had a situation where it did not get the lock although it could be problematic if it didn't. I'll need to work on that aspect, I think the problem may be that the table is not updated with the replace command. I am adding a flush after the unlock (although I thought unlock automatically did a flush) and see if that won't solve the problem.

One user entered applciation and got the submission number 4274, 4275,4276. The next user a little later entered a series of applicatgion which duplicated submission numbers 4275 and 4276. Appear the table was not updated for 4275 and 4276 by the first user.

I'm getting this all over the phone and will not really know until I get to the client later today. I was hoping to have a fix before I get there.

Thanks
Gaylen




>>I use the following code to create sequential numbers compliments of Michael.
>>The code has worked fine until the last several days where it is creating duplicate numbers.
>>
>>
>>LOCAL lnOldSel,lnCompteur
>>lnOldSel=SELECT()
>>lnCompteur=0
>>IF ! USED('key_no')
>> USE key_no IN 0
>>ENDIF
>>SELECT key_no
>>1
>>DO WHILE (NOT RLOCK()) AND (INKEY(0.1)=0) AND lnCompteur<=25
>>   lnCompteur=lnCompteur+1
>>ENDDO
>>REPLACE NUMERO WITH NUMERO+1
>>UNLOCK
>>SELECT(lnOldSel)
>>RETURN key_no.NUMERO
>>
>>
>>
>>The server is Windows 2000 server and using VFP 7.0.
>>
>>
>>Any idea what may be happening or is there an inherent flaw in the code.
>>
>>Thanks
>>Gaylen
>
>What happen, if Key_no table could not be locked() by 25 attempts? You can probably check, if the table was indeed locked and return an ID only in this case. Otherwise you may return null, which would generate an error, which you should handle.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform