Abort_Transaction
See Also: Transactions and DDOs, Begin_Transaction, End_Transaction, DF_TRANABORT_ONERROR, DF_TRANSACTION_ABORT
Purpose
To cancel a transaction that is in progress.
Syntax
Abort_Transaction
What It Does
This command aborts the transaction and rolls back the transaction in progress to the original state. All locked records are released and the lock count is zeroed. There is no need to issue an Unlock command.
Abort_Transaction will not jump to the End_Transaction command in a Begin_Transaction... End_Transaction command block. If an error occurs inside a transaction, the transaction will be aborted automatically, and control will jump to the End_Transaction command in a Begin_Transaction... End_Transaction command block. This is why we expect the Abort_Transaction command to be rarely used (if ever).
Example
Begin_Transaction
Reread Vendor InvHdr
Move "Data Access Corporation" To Vendor.Name
Save Vendor
Save InvHdr
Move False To bTransOK
For i From 1 To 3
Move i To InvItems.LineNumber
Save InvItems
// if any item is DataFlex, this is a good transaction
If (InvItems.Name Contains "DataFlex") Begin
Move True To bTransOK
End
Loop
If bTrans Begin
Unlock
End
Else Begin // Only allow the transaction if DataFlex is purchased.
Abort_Transaction
End
End_Transaction
Notes
-
This command has no effect if executed outside a
Begin_Transaction... End_Transactioncommand block, because it only affects transactions in progress. -
The
Abort_Transactioncommand will not jump to theEnd_Transactioncommand automatically. The flow of the program will continue on the next line.