>>Hi everybody,
>>
>>AFAIK there is no way in multi-user environment to have ID field incremented correctly without using extra table to keep the last ID (if we're not using autoincrement field). Using go bottom, grab the last number and start from there doesn't prevent two users from taking the same ID. Even if we put a check right after for the existance of ID.
>>
>>What do you think? Given only one table and no auto-increment is it possible to correctly auto-increment in multi-user environment?
>>
>>Thanks.
>
>
DO WHILE NOT RLOCK( "0", ALIAS() )
>ENDDO
>* Do here whatever it takes to retrieve a new ID.
>* For example, do a CALC MAX(ID) TO N
>* Then do your INSERT or APPEND
>UNLOCK RECORD 0
>
>Locking the header record will prevent that anybody else can append a record at the same moment. But locking only the header record prevents a lock on other records. That implies that users can continue to work on other records.
>A file lock, the alternative, would fail if any other user has locked a record.
Yes, I was thinking along the same lines again, thanks.
If it's not broken, fix it until it is.
My Blog