Commit
Commit
is used to validate a database transaction.
Commit
# This function debits an account 'ACCOUNT1' and credits and account 'ACCOUNT2' with an AMOUNT value.# It manages a transaction except if a transaction is already in progress.# Returns [V]CST_AOK if the operation was successful, otherwise returns [V]CST_AERROR.Funprog TRANSFER(ACCOUNT1, ACCOUNT2, AMOUNT)Value Char ACCOUNT1(), ACCOUNT2()Value Decimal AMOUNTLocal Integer IF_TRANS# Start the transaction if no transaction is in progressLocal File ACCOUNTIf adxlogTrbegin ACCOUNTIF_TRANS=0Else# The transaction has been started by the calling programIF_TRANS=1Endif# Debit operation (CODE is a unique index so only one database line is updated)Update ACCOUNT Where CODE=ACCOUNT1 With BALANCE=BALANCE-AMOUNTIf fstat# If IF_TRANS=1, the transaction must been aborted by the calling programIf IF_TRANS=0 : Rollback : EndifEnd [V]CST_AERROREndif# Credit operationUpdate ACCOUNT Where CODE=ACCOUNT2 With BALANCE=BALANCE+AMOUNTIf fstat# If IF_TRANS=1, the transaction must been aborted by the calling programIf IF_TRANS=0 : Rollback : EndifEnd [V]CST_AERROREndif# The operation is successful. If IF_TRANS=1, the transaction must been committed by the calling programIf IF_TRANS=0 : Commit : EndifEnd [V]CST_AOK
Commit
is used to validate a database transaction, which is a set of operations that update the database tables (including counters). A transaction is started by a Trbegin instruction.Commit
can only be carried out in the script or subprogram level that started the transaction.Commit
releases all the locks placed on the tables and records and the symbols locked during the transaction. Commit
also releases locks placed before the start of the transaction, except for those placed on symbols.Commit
is executed. Before Commit
, the new or modified data is not visible to other users.Commit
does not return any particular status, except if the buffered database write operations are done by the Writeb
operation. In that case, fstat
will return an error status if a delayed write operation failed (the status has the same value as a Write operation that failed).Code | Description |
---|---|
32 | Transaction started at a higher level of the nesting call. |
48 | No transaction in progress. |
File, Trbegin, Rollback, Onerrgo, Read, Write, Writeb, Rewrite, RewriteByKey, Delete, DeleteBykey, Lock, adxlog.