On 28 Aug 2018, at 6:08 am, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> 
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.

It is and it works well. One gotcha is if you are potentially allocating more 
than 1 ID for the same table within the transaction, you must allocate the new 
IDs within their own transaction, otherwise you just keep getting the same 
(initial) value returned for the next ID,

i.e. in the method that is allocating your new IDs you need to do something 
like:

C_BOOLEAN($vB_InTransaction)

$vB_InTransaction:=Active transaction
If ($vB_InTransaction)
        SUSPEND TRANSACTION
        START TRANSACTION
End if

// allocate the new ID here

If ($vB_InTransaction)
        VALIDATE TRANSACTION
        RESUME TRANSACTION
End if

This requires having the "Allow Nested Transactions" compatibility checkbox 
ticked.
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to