BEGIN TRANSACTION ... END TRANSACTION
BEGIN TRANSACTION
// ...
END TRANSACTIONGroups writes and controls transaction cancellation.
Overview
BEGIN TRANSACTION opens a transaction scope; END TRANSACTION closes that scope. Nested transactions are not independent commits. DisarmTransaction disarms through the outer level and places processing in TTSBREAK: use Break to leave the section through its closing scopes before starting another transaction. The example only shows that flow without writes and does not demonstrate data rollback. TOTVS also warns against wrapping standard ExecAuto calls in external transactions without a routine-specific contract. (TOTVS, n.d., refs. 1–2)
Syntax
BEGIN TRANSACTION
// ...
END TRANSACTIONReturn value
Command without a return; outcome depends on operations and any outer transaction.
Commented example
#Include "Protheus.ch"
User Function EdTrans()
Local lValidated := .F.
Begin Transaction
If !lValidated
// Leave before any write.
DisarmTransaction()
Break
EndIf
End Transaction
Return NilLeaves the disarmed path without writing. Actual rollback requires a dedicated test with custom tables and known operations. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Keep transactions short; avoid dialogs while holding locks. Check called routine contracts before adding an outer transaction.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.