Hi guys, Thanks for all your suggestions and helpful info. After considering all these options, I've come up with a simple solution that seems to work perfectly well, although it hasn't yet been tested comprehensively. The important thing is that all record cancellations go through a *CancelRecord* method. I created a [SpareRecordNumbers] table which contains 3 fields: unique id, table number, and spare record number.
When a new record is created, the *IDNums* method runs: ================================================= *C_LONGINT*($found;$iTableNumber;$iFieldNumber;$newnumber) *RESOLVE POINTER*(*$1*;$var;$iTableNumber;$iFieldNumber) // $1 is a pointer to the record number field // first check to see if there are any spare recordnumbers to be used up $newnumber:=-1 $found:=*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber) *While* (($found>-1) & ($newnumber=-1)) *If* (*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber)>-1) $found:=*Find in field*([SpareRecordNumbers]TableNumber;$iTableNumber) *GOTO RECORD*([SpareRecordNumbers];$found) $newnumber:=[SpareRecordNumbers]RecordNumber *DELETE RECORD*([SpareRecordNumbers]) // just to make sure that another process hasn't beaten us to it ... unlikely but let's be 100% sure *If* (*Find in field*(*$1*->;$newnumber)>-1) $newnumber:=-1 $found:=-1 *Else* *$1*->:=$newnumber *End if* *Else* $found:=0 *End if* *End while* *If* (*$1*->=0) *$1*->:=*Sequence number*(*Table*($iTableNumber)->) *End if* ================================================= When a new record is cancelled, the *CancelRecord* method is called: ================================================= *// first do any necessary checks, eg get the user to confirm that they really do want to cancel* *// if the cancel is to proceed, $cancel:=True* *If* ($cancel) $RecordNumber:=*Field*(iTablenumber;1)-> // all of our data tables have the record number in field 1 *CANCEL TRANSACTION* *If* (yNewRecord)) // yNewRecord flag was set when the record was created *CREATE RECORD*([SpareRecordNumbers]) [SpareRecordNumbers]RecordNumber:=$RecordNumber [SpareRecordNumbers]TableNumber:=iTableNumber *SAVE RECORD*([SpareRecordNumbers]) *UNLOAD RECORD*([SpareRecordNumbers]) *End if* End if ================================================= This doesn't require any locked record checking, copying of flags or variables, or any of that process-slowing activity. If all the data in a table is deleted, the Sequence Number is reset to 0. It's lightning fast. I imported 180,000 records using the old method, and it took almost two hours. Using this method it took less than 10 minutes! That will make our clients happy :) As I said, it hasn't been thoroughly tested yet. So please feel free to chime in if you can see any flaws! Cheers Pat On Mon, 27 Aug 2018 at 21:08, Kirk Brooks via 4D_Tech <[email protected]> wrote: > Hey guys - the very issue with the record counter is sketched out in the > discussion about Suspending Transactions: > > http://doc.4d.com/4Dv16/4D/16.3/Suspending-transactions.300-3652126.en.html > > > I had missed this - it's quite a feature. > > On Mon, Aug 27, 2018 at 7:54 AM Keisuke Miyako via 4D_Tech < > [email protected]> wrote: > > > transactions can be paused since v16 > > > > -- > Kirk Brooks > San Francisco, CA > ======================= > > *We go vote - they go home* > ********************************************************************** > 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] > ********************************************************************** -- ************************************************* CatBase - Top Dog in Data Publishing tel: +44 (0) 207 118 7889 w: http://www.catbase.com skype: pat.bensky ************************************************* ********************************************************************** 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] **********************************************************************

