|
- Network application (ISAM database)
- Locking records
- Error cases
- Temporary files created during the transaction (ISAM database)
- Handling records during a transaction
- Transactions and independent HFSQL context
- OLE DB and Native Accesses
HTransaction (Function) In french: HTransaction
Not available with this kind of connection
Starts a transaction on the data files (HFSQL or accessed via Native Access) and creates the transaction file. What information is saved in the transaction file? Whenever a WLanguage function modifies a data file or an index file during a transaction, the former values of the record and the operation performed are stored in the transaction file. Versions 19 and later
// Start the transaction on the files associated with MyConnection1 HTransaction(MyConnection1) Add_Order() WHEN EXCEPTION IN // Add the order HAdd(Orders) // Validate the addition HTransactionEnd(MyConnection1) DO // Delete the order lines HTransactionCancel(MyConnection1) END
New in version 19
// Start the transaction on the files associated with MyConnection1 HTransaction(MyConnection1) Add_Order() WHEN EXCEPTION IN // Add the order HAdd(Orders) // Validate the addition HTransactionEnd(MyConnection1) DO // Delete the order lines HTransactionCancel(MyConnection1) END
// Start the transaction on the files associated with MyConnection1 HTransaction(MyConnection1) Add_Order() WHEN EXCEPTION IN // Add the order HAdd(Orders) // Validate the addition HTransactionEnd(MyConnection1) DO // Delete the order lines HTransactionCancel(MyConnection1) END
// Start the transaction on the Orders and OrdLine files HTransaction("C:\Temp\Transaction.trs", "Orders,OrdLine,-Customer") Add_Order() WHEN EXCEPTION IN // Add the order HAdd(Orders) // Validate the addition HTransactionEnd() DO // Delete the order lines HTransactionCancel() END
Syntax
Starting a Client/Server transaction on a specific connection Hide the details
<Result> = HTransaction(<Connection name> [, <List of files>])
<Result>: Boolean - True if the transaction was started,
- False if a problem occurred. HErrorInfo returns more details about the error.
<Connection name>: Character string (with or without quotes) - Name of connection to use. This connection was defined:
- hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<List of files>: Optional character string (with quotes) List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign). | | If this parameter is not specified | All the files used during the transaction will be taken into account in the transaction. | If all the files are prefixed by the "-" sign For example: "-Customer, -Product" | All the files specified in the list and used during the transaction will not be taken into account by the transaction. All the files not specified in the list will be taken into account and used during the transaction. | If no file in the list is prefixed by the "-" sign For example: "Customer, Product" | All the files specified in the list and used during the transaction will be taken into account by the transaction. All the files not specified in the list and used during the transaction will not be taken into account by the transaction. | If some files are prefixed by "-" and others are not For example: "-Customer, Product" (equivalent to "Product") | All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction. All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction. The files not specified in the list will be excluded from the transaction |
Starting a Client/Server transaction on a specific connection or an ISAM transaction Hide the details
<Result> = HTransaction(<Connection name> , <Name of transaction file> , <List of files>)
<Result>: Boolean - True if the transaction was started,
- False if a problem occurred. HErrorInfo returns more details about the error.
<Connection name>: Character string (with or without quotes) - Name of connection to use. This connection was defined:
- Empty string ("") or hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<Name of transaction file>: Character string (with quotes) <List of files>: Character string (with quotes) List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign). | | If this parameter is not specified | All the files used during the transaction will be taken into account in the transaction. | If all the files are prefixed by the "-" sign For example: "-Customer, -Product" | All the files specified in the list and used during the transaction will not be taken into account by the transaction. All the files not specified in the list will be taken into account and used during the transaction. | If no file in the list is prefixed by the "-" sign For example: "Customer, Product" | All the files specified in the list and used during the transaction will be taken into account by the transaction. All the files not specified in the list and used during the transaction will not be taken into account by the transaction. | If some files are prefixed by "-" and others are not For example: "-Customer, Product" (equivalent to "Product") | All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction. All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction. The files not specified in the list will be excluded from the transaction |
Starting an ISAM and/or Client/Server transaction on all the HFSQL Client/Server connections (existing ones or future ones) Hide the details
<Result> = HTransaction([<Name of transaction file> [, <List of files>]])
<Result>: Boolean - True if the transaction was started,
- False if a problem occurred. HErrorInfo returns more details about the error.
<Name of transaction file>: Optional character string (with quotes) <List of files>: Optional character string (with quotes) List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign). | | If this parameter is not specified | All the files used during the transaction will be taken into account in the transaction. | If all the files are prefixed by the "-" sign For example: "-Customer, -Product" | All the files specified in the list and used during the transaction will not be taken into account by the transaction. All the files not specified in the list will be taken into account and used during the transaction. | If no file in the list is prefixed by the "-" sign For example: "Customer, Product" | All the files specified in the list and used during the transaction will be taken into account by the transaction. All the files not specified in the list and used during the transaction will not be taken into account by the transaction. | If some files are prefixed by "-" and others are not For example: "-Customer, Product" (equivalent to "Product") | All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction. All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction. The files not specified in the list will be excluded from the transaction |
Remarks The added, modified or deleted records in a transaction are locked in write mode. - Nesting transactions: The transactions cannot be nested (HTransaction cannot be called in a transaction). In this case, the error 70031 occurs.
- A fatal error is displayed in the following cases:
- A transaction is started on all the connections while there is at least one connection in transaction.
- A transaction is started on a connection while a transaction was already started on all the connections.
- A transaction is started on all the connections while there is at least one connection whose isolation mode is not "Read Uncommitted".
Handling records during a transaction Transactions and independent HFSQL context When copying a context, if a transaction is in progress on the first context, the new context is not in transaction. You must call HTransaction to start a transaction in the new context.
This page is also available for…
|
|
|
| |
| Click [Add] to post a comment |
|
| |
|
| |
| |
| |
| |
| |
| |
| | |
| |