🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.databases
2 messages
2 total messages Started by Graydon Patterson Sun, 24 Jan 1993 02:06
Re: 4D Field Incrementing
#652
Author: Graydon Patterson
Date: Sun, 24 Jan 1993 02:06
15 lines
836 bytes
Here is the standard procedure I use to create unique ID's..
`	NextID
$0:=[NextID]ID
[NextID]ID:=[NextID]ID+1
SAVE RECORD([NextID])
`    end script

To obtain a unique ID in any file use the following...
[Clients]Client Number:=NextID    ` NEXTID being a function

The NextIF file has only one field called ID and only one
record, the next ID to be called.
(pardon my typos)
-- 
Re: 4D Field Incrementing
#653
Author: Erik Oliver
Date: Sun, 24 Jan 1993 13:59
32 lines
1674 bytes
In article <1993Jan24.020602.20467@freenet.carleton.ca> aa192@Freenet.carleton.ca (Graydon Patterson) writes:
>
>Here is the standard procedure I use to create unique ID's..
>`	NextID
>$0:=[NextID]ID
>[NextID]ID:=[NextID]ID+1
>SAVE RECORD([NextID])
>`    end script
>
>To obtain a unique ID in any file use the following...
>[Clients]Client Number:=NextID    ` NEXTID being a function
>
>The NextIF file has only one field called ID and only one
>record, the next ID to be called.
>(pardon my typos)
>-- 
>

NO NO NO NO NO.  What if this was a multi-user database, what if lots of
people all over the world tried to get a new ID simultaneously, two
people might both assing $0 := [NextID]ID, and both might get the exact
same value before raising the value of [NextID]ID, in Comp. Sci. terms,
you have a _race condition_.

If you feel the need to use this solution, turn this procedure into a
TRANSACTION, or use the SEMAPHORE features of 4D to protect against this
happening.

But, if you really need Unique IDs, NEVER NEVER NEVER use the above
procedure in a multi-user database, or even in a single user databse

-Erik
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads