Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

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=0
loop until locked
	lock filevar, id then
		locked=1
	end else	
		unlock filevar, id else null
		call Delay(1)
	end	
repeat	
readv seqkey from filevar,id,1 else null		
nextkey=seqkey + 1	
writev nextkey to filevar,id,1 else
	retval=Set_FSError()
end
unlock filevar, id else null

end else

retval=Set_FSError()

end

return seqkey

View this thread on the forum...