Sequential Key in OI (OpenInsight Specific)
At 24 FEB 1998 08:58:45PM Dave Potter wrote:
I need to create a new record in a table with a
stored procedure. However the record uses a sequential
key. How can I find the next value in the sequential
key so I can use that number for my record as well as
update the sequential key marker so the key is notused again.
Thanks in advance
At 25 FEB 1998 12:30AM Barry Stevens wrote:
compile function get_seqkey(tablename)
declare function Set_FSError
equate id to '%SK%'
seqkey=1
open "DICT",tablename to filevar then
locked=0loop until lockedlock filevar, id thenlocked=1end elseunlock filevar, id else nullcall Delay(1)endrepeatreadv seqkey from filevar,id,1 else nullnextkey=seqkey + 1writev nextkey to filevar,id,1 elseretval=Set_FSError()endunlock filevar, id else nullend else
retval=Set_FSError()end
return seqkey