ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / Managing transactions
  • Overview
  • What is a transaction?
  • Using the transactions according to your requirements
  • Principle
  • Principle of transactions on HFSQL data files
  • Special cases
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
What is a transaction?
A transaction is a set of indissociable operations: either all the operations of the transaction are performed, or none is performed. The management of transactions is the best way to ensure the integrity of a set of indissociable write operations performed on HFSQL data files.
For example, in a banking application, a transfer operation consists in debiting an account to credit another one. These two operations must be managed in a single transaction in order to avoid any incoherence (in case of power outage during the operation for example).

Using the transactions according to your requirements

Depending on your situation, let's see some tips for optimizing the management of transactions in your applications or sites:
  • Start transactions in applications installed on reliable computers (UPS, only one application running, etc.): disk transaction
    In this case, the purpose of transactions is to be able to cancel a set of operations. It is possible to display windows in the middle of a transaction, to perform different lengthy processes, ...
    Each operation performed during the transaction is saved in a transaction file. The record used is locked in write mode until the transaction is validated or canceled.
  • Perform trusted write operations in the data files (banking sector, accounting, ...).
    The transactions are used to insure the security of a set of operations. In this case, you must group all the write operations in your code in order to run them in a transaction. The code run during the transaction must display no window, must browse no data file, ... This code must only contain the operations for modifying the data files.
    Each operation performed during the transaction is saved in a transaction file. The record used is locked in write mode until the transaction is validated or canceled.
Principle

Principle of transactions on HFSQL data files

Each write operation performed during a transaction is stored in a transaction file. The transaction can be canceled at any time: all operations performed since the beginning of transaction will be canceled.
Once the write operations included in the transaction are completed, the program can validate the operations of the transaction.
Remarks:
  • HFSQL Classic The transaction isolation level used is "READ UNCOMMITED".
  • HFSQL Client/Server The transaction isolation level is defined with HTransactionIsolation. The default isolation level is the "READ UNCOMMITED" mode.

Special cases

  • Error in the program, the transaction is automatically abandoned.
  • Call to EndProgram, the transaction is automatically abandoned.
  • Test canceled from the editor, the transaction is automatically abandoned.
  • Power outage or unexpected stop of the application (application stopped by the task manager for example):
    When the application is restarted, the consistency of the database can be restored:
HFSQL Client/Server Special cases specific to HFSQL Client/Server:
  • If the Client is lost, the transaction is cancelled.
  • Restarting the server cancels the current transactions. Caution: the transaction is not canceled if the transaction applies to a data file with secure password. The transaction will be canceled during the next opening of the data file.
For more details, see Managing special cases.
Related Examples:
WD Transaction Training (WINDEV): WD Transaction
[ + ] This program, powered by WINDEV, is based on a simplified analysis (ORDERS, ORDERLINE and STOCK). It illustrates the operating mode of the transactions when placing an order.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/07/2023

Send a report | Local help