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 ------------------------------------------------------------------------------------------------ Chuck Miller Voice: (617) 739-0306 Informed Solutions, Inc. Fax: (617) 232-1064 mailto:cjmiller<AT SIGN>informed-solutions.com Brookline, MA 02446 USA Registered 4D Developer Providers of 4D and Sybase connectivity http://www.informed-solutions.com ------------------------------------------------------------------------------------------------ This message and any attached documents contain information which may be confidential, subject to privilege or exempt from disclosure under applicable law. These materials are intended only for the use of the intended recipient. If you are not the intended recipient of this transmission, you are hereby notified that any distribution, disclosure, printing, copying, storage, modification or the taking of any action in reliance upon this transmission is strictly prohibited. Delivery of this message to any person other than the intended recipient shall not compromise or waive such confidentiality, privilege or exemption from disclosure as to this communication. > On Aug 25, 2018, at 10:10 AM, Pat Bensky via 4D_Tech <[email protected]> > wrote: > > Using v17 ... > > I'm looking at ways to update our ancient record numbering system, and I > think I should be able to do it efficiently with CALL WORKER, but having a > bit of trouble getting my head around it. > > The record numbers are like invoice numbers: each must be unique, and we > don't want to have any gaps in the numbering sequence. So we need to keep > track of any record numbers that are created and then abandoned (eg if a > user creates a new record and then cancels it). > The old system works well but it uses semaphores and SET/GET PROCESS > VARIABLE and DELAY PROCESS. I isn't very efficient, especially when a large > number of records are being imported and each one needs a new record number. > Record numbers must be assigned synchronously - processing must not > continue until the new record number has been assigned. Also, this > frequently needs to be done in a context where there is no active form, so > CALL FORM won't work. > > As I see it, we'll need to call a worker, which calls the worker that > assigns the record number. > The first worker has to wait until the second one has created the new > number. > Then the original method, that called the first worker, must wait until the > first worker gets the new number. It seems that this won't be much better > than the old method. > > Am I completely barking up the wrong tree? Is this not an appropriate use > for workers? Or have I misunderstood something? > > Pat ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

