Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NewID() working randomly
Message
From
18/08/1999 08:49:06
 
 
To
18/08/1999 08:31:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00254709
Message ID:
00254908
Views:
19
>>I'm using a NewID() function to lookup "NextKey" values for adding records to my database. This function suites my needs perfectly when it works, but for some reason, it doesn't always work. I haven't pinned down what changes occur in my project that disable this function, but they're NOT changes in the DB, as that has been unchanging.
>>
>>* Excerpt from function NewID()
>>*=================================
>>IF ! USED("rv_nextkey")
>> USE "eis!rv_nextkey" IN 0
>>ELSE
>> REQUERY("rv_nextkey")
>>ENDIF
>>
>>IF _TALLY = 1
>> MESSAGEBOX("_Tally was successfull")
>> SELECT rv_nextkey
>> llSuccess = .F.
>> DO WHILE ! llSuccess
>> lnRetVal = rv_nextkey.nextkey
>> REPLACE rv_nextkey.nextkey WITH rv_nextkey.nextkey + 1
>>*etc..
>>*=================================
>>
>>I've been stepping through the above code and for some reason the USE "eis!rv_nextkey" IN 0 isn't returning _TALLY = 1
>>
>>The entry for _TALLY in Hacker's Guide doesn't list USE as being a command that changes _TALLY, but, as I said, this code does work sometimes. (The code actually came from another FVP book, so somebody else thought it should work as well).
>>
>>Browsing the NextKey table with the correct parameters gives the expected results, I just can't figure out why this function is inconsistent.
>>
>>Any suggestions?


You know...it helps if you enter the reply before clicking on Send.


I have some problems with this code. What is to prevent two users from grabbing the same ID? I don't see any record locking. It really can't be implicit in this case. There is routine on my website that will work properly.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform