BEGIN_TRANSACTION
Begin a transaction.
See also END_TRANSACTION, ABORT_TRANSACTION,
COMMIT, and ROLLBACK.

Format
 Begin_transaction [/Qualifiers... ]
 the BEGIN_TRANSACTION statement enables you to mark the beginning of a transaction. A transaction consists of one or more database updates which, because of their nature, must be treated as one autonomous unit. These updates may occur across multiple files. For example, a debit and credit must be treated as an autonomous unit in order to maintain accounting integrity.
 You can use BEGIN_TRANSACTION in conjunction with END_TRANSACTION and other available transaction statements to ensure that no part of a transaction is carried out if the entire transaction cannot be carried out. In the case of the debit/credit example, you can ensure that a debit never takes place without its associated credit. Either the entire transaction completes, or no portion of the transaction takes place at all.
 A BEGIN_TRANSACTION statement may not be executed while another transaction is current (i.e. no nesting is allowed). Additionally, while a transaction is current, databases cannot be closed. Either case results in the generation of an error if attempted.
 Any record locks that are active when a BEGIN_TRANSACTION statement is executed remain active, in spite of any attempted UNLOCKS, until an END_TRANSACTION is executed. Once the END_TRANSACTION is executed, record lock status is as it normally would have been if a transaction had never been defined.
 For RMS files, Recovery Unit (RU) journaling implements transactions. You may begin a transaction regardless of whether or not RU journaling has been enabled for data files. However, data integrity is only ensured for data files marked for RU journaling. When an IDML program terminates for any reason (e.g. system crash, normal program exit, etc.), and a transaction is current, all data files marked for RU journaling are restored to their state prior to the occurrence of the transaction.

Qualifiers
/Fail=LABELLabel to which to branch if the statement fails.
If LABEL is %EXIT, exit the routine or loop.
If in a loop, and LABEL is %CONTINUE, continue the loop. If not in a loop, and LABEL is %CONTINUE, an error message displays.
 /Succeed=LABELLabel to which to branch if the statement succeeds.
If LABEL is %EXIT, exit the routine or loop. If in a loop, and LABEL is %CONTINUE, continue the loop. If not in a loop, and LABEL is
%CONTINUE, an error message displays.
 /NofailDo not signal an error. Instead, set the
internal variable %FAIL.

Example
 !******************************
 ! Form TRANSFER
 !******************************
 
 Form TRANSFER &
 /Pos=2, 10 /Size=3,60 &
 Border="Transfer funds" &
 /Flow &
 /Text=1, 15, "Checkings balance:" &
 /Text=2, 16, "Savings balance:" &
 
 Output CHECKING_BAL(BALANCE) /Pos=1,33
 Output SAVINGS_BAL(BALANCE) /Pos=2,33
 
 If xfer_direction = "Checking_to_savings"
 prompt = "Checking to savings:"
 Else
 prompt = "Savings to checking:"
 End_if
 
 Loop
 ! Get balance records for update
 Get "1" in CHECKING_BAL /Lock=Write
 Get "1" in SAVINGS_BAL /Lock=Write
 Show/Outputs
 
 ! Get amount to be transferred
 Input amount /Pos=3,33 &
 /Exit=END &
 /Prompt=prompt &
 /Using=CHECKING_BAL(BALANCE) &
 /Verify=MUST_BE_POSITIVE
 
 ! Begin a transaction
 Begin_transaction
 ! Update the balances
 If xfer_direction = "Checking_to_savings2
 If CHECKING_BAL(BALANCE) amount then
 Error "Checking account went negative."
 CHECKING_BAL(BALANCE) = CHECKING_BAL(BALANCE) - amount
 SAVINGS_BAL(BALANCE) = SAVINGS_BAL(BALANCE)+ amount
 Else
 If SAVINGS_BAL(BALANCE) = amount
 SAVINGS_BAL(BALANCE) = SAVINGS_BAL(BALANCE) - amount
 CHECKING_BAL(BALANCE) = CHECKING_BAL(BALANCE) + amount
 Else
 ! Insufficient funds in savings, abort the transaction and re-prompt
 Error "Insufficient funds in savings account."
 Abort_transaction
 Continue
 End_if
 End_if
 Show /Outputs
 ! Prompt to accept the transfer of funds. If the transfer is accepted,
 ! end the transaction with the already updated balances. If the transfer
 ! is rejected, rollback the transaction (restoring the balances to their
 ! states prior to the beginning of the transaction.
 Menu ACCEPT
 If %ITEM = "YES" then
 Message "Transaction accepted."
 End_transaction
 Else
 Message "Transaction not accepted. Accounts reset to previous state."
 Abort_transaction ! (Rollback)
 End_if
 End_loop
 END:
 Endform