ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Locking records
  • Error cases
  • Handling records during a transaction
  • Transactions and independent HFSQL context
  • OLE DB and Native Connectors
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Starts a transaction on the data files (HFSQL or accessed via a Native Connector) 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.
HFSQL Client/Server This function proposes two operating modes of transactions:
  • The transaction can be started on a connection: in this case, only the data files associated with this connection are transacted. This mode is required to manage the isolation levels of transactions.
  • The transaction can be started on all HFSQL connections (existing ones or future ones). In this case, <Connection variable>.Transaction starts both an HFSQL Classic transaction (ISAM) and an HFSQL Client/Server transaction.
Note: This function is equivalent to <Connection variable>.TransactionStart.
Example
MaConnexion1 is Connection

// Début de la transaction sur les fichiers de données associés à la connexion MaConnexion1
MaConnexion1.Transaction()
Ajout_Commande()
WHEN EXCEPTION IN
	// Ajout de la commande
	Commande.Ajoute() 
	// Validation de l'ajout
	MaConnexion1.TransactionEnd()
DO
	// Suppression des lignes de commandes
	MaConnexion1.TransactionCancel()
END
Syntax

Starting a Client/Server transaction on a specific connection Hide the details

<Result> = <Connection>.Transaction([<List of data files>])
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurs. HErrorInfo returns more details about the error.
<Connection>: Connection variable
Name of the Connection variable that describes the connection to use.
<List of data files>: Optional character string
List of logical names of one or more data files to take into account (or not) in the transaction (in this case, the data file name is preceded by the "-" sign).
If this parameter is not specifiedAll data files used during the transaction will be taken into account in the transaction.
If all data files are prefixed with the "-" sign
For example: "-Customer, -Product"
All data files specified in the list and used during the transaction will not be taken into account by the transaction.
All data files not specified in the list will be taken into account and used during the transaction.
If no data file on the list is prefixed with the "-" sign
For example: "Customer, Product"
All data files specified in the list and used during the transaction will be taken into account in the transaction.
All data files not specified and manipulated during the transaction will be ignored in the transaction.
If some data files are prefixed with "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All data files in the list prefixed with "-" and used during the transaction will be ignored in the transaction.
All data files in the list not prefixed with "-" and used during the transaction will be taken into account in the transaction.
Data files not specified in the list will be excluded from the transaction.

OLE DBNative Connectors (Native Accesses) This parameter is ignored. All the data files associated with the connection are in transaction on the native server.

Starting a Client/Server transaction on a specific connection Hide the details

<Result> = <Connection>.Transaction(<Transaction file> , <List of data files>)
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurs. HErrorInfo returns more details about the error.
<Connection>: Connection variable
Name of the Connection variable that describes the connection to use.
<Transaction file>: Character string
HFSQL Classic Full name of the transaction file (used to store the operations performed within the transaction). This file will be automatically deleted when using <Connection variable>.TransactionEnd or <Connection variable>.TransactionCancel.
If this name is an empty string, the transaction file will be created in the application's data file directory with the name: <Nom Projet>_$TRS_OPERATION.TRS.
HFSQL Client/ServerOLE DBNative Connectors (Native Accesses) This parameter is ignored. This parameter is taken into account for the HFSQL Classic transactions only (ISAM transactions).
<List of data files>: Character string
List of logical names of one or more data files to take into account (or not) in the transaction (in this case, the data file name is preceded by the "-" sign).
If this parameter is not specifiedAll data files used during the transaction will be taken into account in the transaction.
If all data files are prefixed with the "-" sign
For example: "-Customer, -Product"
All data files specified in the list and used during the transaction will not be taken into account by the transaction.
All data files not specified in the list will be taken into account and used during the transaction.
If no data file on the list is prefixed with the "-" sign
For example: "Customer, Product"
All data files specified in the list and used during the transaction will be taken into account in the transaction.
All data files not specified and manipulated during the transaction will be ignored in the transaction.
If some data files are prefixed with "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All data files in the list prefixed with "-" and used during the transaction will be ignored in the transaction.
All data files in the list not prefixed with "-" and used during the transaction will be taken into account in the transaction.
Data files not specified in the list will be excluded from the transaction.

OLE DBNative Connectors (Native Accesses) This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
Remarks

Locking records

The added, modified or deleted records in a transaction are locked in write mode.

Error cases

  • Transaction nesting: It is impossible to nest transactions (i.e. to call the function <Connection variable>.Transaction within a transaction).. In this case, 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 level is not "Read Uncommitted".

Handling records during a transaction

During a transaction, some rules must be complied with when handling the records. For more details, see Transactions: Handling the 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 <Connection variable>.Transaction to start a transaction in the new context.
WINDEVUser code (UMC)OLE DBNative Connectors (Native Accesses)

OLE DB and Native Connectors

Only syntaxes with connection are taken into account by the Native Connectors that support transactions. You can also use SQLTransaction.
Component: wd300.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help