Begins, commits, rolls back, or shows the state of a transaction
Syntax
AX_Transaction( <nTransactionType> ) -> logical
<nTransactionType> |
Specifies the transaction command to be carried out. The constants used with Advantage are described in the Constants section below. |
Returns
True if the command was successful, False if not.
Constants
AX_BEGIN_TRANSACTION
Marks the beginning of an Advantage TPS transaction. From this point on in your application until an AX_COMMIT_TRANSACTION or AX_ROLLBACK_TRANSACTION, every append and replace command issued before a corresponding commit or rollback will be considered one transaction.
Once you begin an Advantage transaction, any updates made to the database are tracked in a transaction log file. Other users sharing the same database files will not see any changes to the database until the transaction is committed. When the transaction is committed, the changes are written to the database files and indexes.
AX_COMMIT_TRANSACTION
Indicates the end of a transaction and signifies all updates issued during the transaction be written to the database. These updates are made visible to all other users at this time.
AX_ROLLBACK_TRANSACTION
Indicates the end of a transaction and signifies all updates issued during the transaction be aborted. All of the data altered since the beginning of the transaction is restored to its previous value. The pending updates are rolled back and cannot be recovered.
AX_ISACTIVE_TRANSACTION
Indicates if the user is currently in a transaction (.T.) or not (.F.).
Note A call to AX_Transaction( AX_BEGIN_TRANSACTION ) begins a transaction on all existing Advantage connections that do not already have transactions active. If you wish to begin a transaction on a specific Advantage connection only, you can either call the Advantage Client Engine AdsBeginTransaction API or modify the AX_Transaction code in the DBFAXS.AEF file to accept an Advantage connection handle as a parameter.
Description
This function is the main function for the Advantage TPS. All the transaction command statements are issued from this function.
Object-oriented Example
See CLASS AxDBServer for code sample for the AxDBServer class.
oDB := AxDBServer{ "TEST", .F., .F., "DBFNTXAX" } |
|
? oDB:AX_Transaction() // Returns .F. |
|
oDB:AX_Transaction( AX_BEGIN_TRANSACTION ) |
? oDB:AX_Transaction() // Returns .T. |
oDB:Append() |
oDB:AX_Transaction( AX_COMMIT_TRANSACTION ) |
|
? oDB:AX_Transaction() // Returns .F. |
Procedural Example
USE test VIA "DBFNTXAX" |
|
? AX_Transaction() // Returns .F. |
|
AX_Transaction( AX_BEGIN_TRANSACTION ) |
? AX_Transaction() // Returns .T. |
DBAppend() |
AX_Transaction( AX_COMMIT_TRANSACTION ) |
|
? AX_Transaction() // Returns .F. |