Default key assigment (OpenInsight)
At 09 NOV 2000 04:18:21PM Blair Massey wrote:
We have a client that has several folks doing simultaneous order entry on our application. He reports a problem I sure some of you folk have encountered. I enclose his email to me asking for your help:
*
Good talking to you yesterday.
This is more an FYI note than an appeal for help, although if you have any ideas I'd like to hear them.
I had mentioned a record-locking issue a couple of weeks ago in an e-mail to you, and here are the details:
If multiple users try to open the same record, OI Server Service catches the access and notifies the users, offering read only views. This applies to any records that have been committed to the database.
HOWEVER……
If one user completes order #123, closes it, and Buyer offers order #124, order #124 does not exist in the Buyer database, so when user #2 opens Buyer and is assigned an order number, it is also #124. I have tried this and it does happen.
User #1 writes his #124 order, unaware that user #2 is working on the same order number.
User #1 finishes first, commits the record #124 to the database.
User #2 finishes their version of order #124 and commits it to the
database.
User #1 has their order #124 overwritten by the last committed transaction and it does not exist.
Buyer is running on the server, so actually only one application is
running. Is there any way a record-number assignment routine could be
developed?
OI's record-locking is performing as designed, this appears to be a
function of the Buyer application.
Could the program limit assignment of order numbers?
Again, another complex networking issue.
Appreciate your "(open) insight" into this problem.
*
Thanks for any ideas!
Blair
At 09 NOV 2000 05:01PM Oystein Reigem wrote:
Blair,
I distinctly remember that issue has been raised here before… (doing a search) …uh… …by me! (Blush).
- Oystein -
At 09 NOV 2000 06:11PM Donald Bakke wrote:
Blair,
As Oystein has mentioned, this is an issue that has been raised before. Some would contend that this is a carry-over from AREV's problems with sequential key counters.
Unfortunately (or fortunately) none of our clients have experienced this issue with OI. Yes, users can get the same default key to appear but only one will get the record lock. I assume you are using the SEQKEY default and not running your own custom method?
If you search enough on this board and the "public" one you should find many posts that describe how using a default of "" instead of the SEQKEY and then programmatically assigning the key is done. People have claimed this avoids the problems with SEQKEY.
dbakke@srpcs.com
At 10 NOV 2000 02:07PM Paxton Scott wrote:
Hi Blair,
In the fwiw (for what its worth) category, we had this problem and finally resolved it by using our own code to retrieve the next key and update %SK% at once. This does cause some 'holes' in the list of keys in the database, as a user may get a key and then not 'save' the new record (close the form without saveing). But, it avoids the case of 2 users having the same key and the "2nd" user being unable to save is new record without overwriting the first user's record. Let me know if I can help more. paxton@arcscustomsoftware.com[url=http://www.arcscustomsoftware.com/]ARCS, Inc.
At 11 NOV 2000 01:27AM Barry Stevens wrote:
Using ] as the default in KeyField
In the write event script do:
call MyProg("WRITE","@SELF")return 0Code in MyProg
WinId=@Window ;*]")
ID=]"endif]" thengosub WriteWithNextKeyif EventError then returnID=NewKeyend elsecall set_eventstatus(0)forward_event()EventError=Get_EventStatus(eventcode)if EventError then returnend
*POST WRITE (Post write code here) return ! WriteWithNextKey: !**
Determine the key controlskeyCount=count( keyMap@, @FM) + ( keyMap@ NULL$)keyControls=NULL$for keyNbr=1 to keyCountkeyControls := keyMap@ : @RMnext keyNbrkeyControls-1,1=NULL$oldKey=get_property( keyControls, 'DEFPROP')if oldKey-1,1=@RM thenoldKey-1,1=NULL$endconvert @RM to '*' in oldKeylocate keyMap@ in controlMap@ using @fm setting pos elsereturn 0endtableName=controlSemantics@open tableName to hTableName elsereturn 0endDictKey=%SK%"NextNo= get_next_sk(TableName)NewKey=NextNorowLocks@=newKeyconvert '*' to @FM in newKeyOrigResultRow@=newKey : @FM : ""convert @FM to @RM in newKeyproperties=str( 'DEFPROP' : @RM, keyCount)properties-1,1='unUsed=set_property( keyControls, properties, newKey)call Set_EventStatus(0)forward_event()EventError=Get_EventStatus(eventcode)if EventError thenopen "DICT",TableName to hDict thenSk=DictKeyloop until lock_record(hDict,Sk);repeatreadv SkKey from hDict,Sk,1 thenif SkKey=NextNo+1 thenwritev NextNo to hDict,Sk,1 else nullendendunlock hDict,Sk else nullendunlock hTableName,NewKey else nullNewKey=]"rowLocks@=Null$OrigResultRow@=]" : @FM : ""properties=str( 'DEFPROP' : @RM, keyCount)properties-1,1='unUsed=set_property( keyControls, properties, newKey)setproperty('@','ID',]")end elsemsg(@Window,"Your Order number is ":NewKey)endreturn
At 14 NOV 2000 09:09AM Blair Massey wrote:
Gentlemen,
Thanks for your posts! You have most helpful. Sorry it took so long to get back here and thanks you. Things have been a bit hectic and this fell to the back burner. I'm sure we can get the problem solved from here with your suggestions.
Blair