We have been using Sequence Number for years without any problem. It depends 
how/when you use it

My suggestion is to make use of newer features such as Auto-increment on either 
UUID or Longint. If you don't want to use auto-increment for whatever reasons, 
you could call it at Trigger for new record. If you're paranoid like me, use 
following
codes to call sequence number.

ES_SequenceNo($error;->UniqueField) -> $error 

C_LONGINT($seqNo;$0;$1;$error;$F)
C_POINTER($2;$pSeqkey;$pTable)
$error:=CheckError_T ($1) //check if there's previous error
If ($error=0)
$pSeqkey:=$2
If ($pSeqkey->=0)  //only if auto-increment wasn't activated yet
$pTable:=FieldToFilePtr ($2)`return table pointer
$SeqNo:=Sequence number($pTable->)
$F:=Find in field($pSeqkey->;$SeqNo)
If ($F=-1)
$pSeqkey->:=$seqNo
Else 
$error:=SetError ($error;-17160)
End if 
End if 
End if 
$0:=$error

Alan Chan

4D iNug Technical <4d_tech@lists.4d.com> writes:
>Hi all,
>
>I ran into an issue while using SEQUENCE NUMBER in 4D v15.4, in a 
>client-server setup.
>
>I put the result in a field called ‘ID’, which is the primary key for that 
>table, and by default is unique. Auto increment is off.
>The code is running in a transaction.
>
>Frequently, users get the error ‘Cannot save the record, DUPLICATE KEY’.
>Then, I go to the structure and rebuild the index on that field (ID).
>
>They try again, and the record is saved without a problem.
>
>After a while, though, and after other users have added records to this table, 
>the problem re-occurs.
>Rebuilding the index again fixes the problem.
>
>I have exported the data to a tab delimited file, truncated the table, and 
>imported the data. Problem is still there.
>I have compacted the data file. Same problem.
>
>Any ideas what can be the cause?
> 
>Kind regards,
>
>Rudy Mortier
>Two Way Communications bvba  -----------------
>

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to