SEQKEY (OpenInsight 32-bit Specific)
At 05 AUG 2005 10:13:27AM Don Pederson wrote:
I have been reading on the forum (2003 posts), that it is not advisable to use SEQKEY when you have multiple users adding and updating the same data file due to the possibility of more than one person getting the same key and the last save overwriting the previous. Is this still a problem? Is the %SK% field not incremented until after the new record is saved, or has that been fixed so that it is incremented immediately?
If it is best to work around it, is there code posted anywhere to do this?
Don Pederson
At 08 AUG 2005 09:28AM Paxton Scott wrote:
Don,
I use this function. It will leave "holes" if the user gets a key and
does not save the new record, but I never worry about that.
Compile Function ARCS_GetSeqKey(filename)
Open "DICT.":filename to hdfile then
Read rec from hdfile,"%SK%" Thenthiskey=recnextkey=thiskey + 1End Elsenextkey=1EndWrite nextkey on hdfile,"%SK%" thenEndReturn nextkeyEnd
REturn 0
At 08 AUG 2005 03:00PM Matt Sorrell wrote:
Paxton,
Shouldn't you include a "locking loop" before reading the %SK% record? Otherwise, you could potentially run into a duplicate key issue if two users tried to set up a new record at the same instant.
I acknowledge that the possibility is remote, but I always used a lock when I had a routine almost identical to that.
At 11 AUG 2005 06:01AM Richard Guise wrote:
Re this and responses to date.
As far as I am aware the standard SEQKEY (usually!) works fine on networks including locking of %SK% (which seems prudent if not essential).
However, we had a problem a year or two ago with 4+ users hammering new records into the same file at high speed on a slightly slow network. Just occasionally the odd new record simply didn't get filed.
Couldn't find cause or fix so wrote simple replacement procedure which has been fine ever since. Default key is "New Entry" and a pre-save script detects this, finds next key and does the necessary.
Hope this helps.