That is exactly what we do for our code. Has served us well for all our sites. 
We can have 200+ current users on the system, importing records from labs (thus 
needing lots of counters quickly), and never noticed a problem with the system. 
For those counters we do not wanted to have one go missing we have a BLOB to 
hold for use next time. 

The reason we use our own counters rather than 4D’s auto assigned number is 
that we are often importing records from previous systems. We can easily roll 
back the counters when and where needed. We also like to put a good block of 
unused numbers between what was imported and what has been created by the 
system. That way looking at the unique numbers the Admins and us can know 
quickly where the record came from. This is specifically important when the 
system is first used.


Jody Bevan

Argus Productions Inc. <>
+1 587-487-6120

> On Aug 26, 2018, at 7:37 PM, Chuck Miller via 4D_Tech <> 
> wrote:
> OK i have done this many times with a table. You have multiple records in the 
> table, one for each id you need. I usually make that records key name 
> ([table]field). If you have to keep track of released numbers, you can add a 
> blob field. I would not be adding object fields as you can not access using 
> SQL. I also have never figured out why you need a semaphore. I think in olden 
> days (v1, 1.5 etc) you needed to slow this down to some extent.
> You have be cognizant of whether you are inside a transaction or not. these 
> queries and updates are blazing since you always have relatively few records 
> in the table. If you have 500 keys you will have 500 records. Run method. 
> Query for key. Load record if locked wait retry load. See if you have any 
> returned numbers otherwise set next number, save record, unload record return 
> it.
> Pat when you say you need to use all numbers what happens in the following 
> scenario. You create a record and it gets ID 100, for the next months you 
> create 10,000 more records. You then decide to delete 1000, would you reuse 
> that number. or only reuse if cancelling out of creation. If the later why 
> not simply assign right before you save
> Regards
> Chuck
> ------------------------------------------------------------------------------------------------

4D Internet Users Group (4D iNUG)

Reply via email to