ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / SQL functions
  • Syntax 2: Performing a transaction on a connection
  • Nesting transactions
  • Locks and transactions
  • Native MySQL Connector
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
SQLTransaction (Function)
In french: SQLTransaction
Begins, commits or rolls back a transaction:
  • on the files of a database opened by SQLConnect,
  • on the files of a database opened by a connection (OLE DB or Native Access/Native Connector) described in the data model editor or by HOpenConnection.
Note: This function is the only SQL function that can be used with HFSQL functions (for example, to perform transactions on a third-party database manipulated with HFSQL functions).
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)AjaxOLE DB
NumConnexion is int = SQLConnecte("MaBase", "User", "MotDePasse", "", ...
		"OLEDB", "MonProvider")
IF NumConnexion = 0 THEN
	SQLInfo()
	Error("Erreur d'ouverture de la connexion: " + SQL.MesError)
ELSE
	// Mise en transaction de la connexion
	SQLTransaction(sqlStart)
	// Modification de la valeur de toutes les rubriques UnFichier.UneRubrique
	IF SQLExec("UPDATE UnFichier SET UneRubrique = 'nouvelle valeur'", ...
		"RequeteModif") = True THEN
		// Termine la transaction
		SQLTransaction(sqlCommit)
	ELSE
		SQLInfo("RequeteModif")
		Error("Erreur d'exécution de la requête: " + SQL.MesError)
		// Annulation de la transaction
		SQLTransaction(sqlRollBack)
		// Le contenu du fichier UnFichier n'a pas changé
	END
END
Syntax

Transaction on the files of a database opened by SQLConnect Hide the details

<Result> = SQLTransaction(<Indicator>)
<Result>: Boolean
  • True if the operation was performed,
  • False otherwise.
<Indicator>: Integer constant
Type of transaction operation to perform:
sqlCommitEnd the transaction.
sqlRollBackCancels the transaction.
sqlStartStarts the transaction.
Note: This syntax is not available in Android.
WINDEVWEBDEV - Server codeWINDEV MobileReports and QueriesAndroidAndroid Widget User code (UMC)Ajax

Transaction on the files of a database opened by a connection described in the analysis or by HOpenConnection Hide the details

<Result> = SQLTransaction(<Indicator> , <Connection>)
<Result>: Boolean
  • True if the operation was performed,
  • False otherwise.
<Indicator>: Integer constant
Type of transaction operation to perform:
sqlCommitEnd the transaction.
sqlRollBackCancels the transaction.
sqlStartStarts the transaction.
<Connection>: Character string
Name of the connection used to access the database. This name was defined in the data model editor or by HOpenConnection. This connection must have been described during the call to SQLTransaction. If the connection is not opened during the call to SQLTransaction, the specified connection is automatically opened.
Remarks

Syntax 2: Performing a transaction on a connection

To perform a transaction on a connection, you must:
  1. Start the connection (SQLTransaction(sqlStart)).
  2. Perform the operations on the data files with the relevant HFSQL functions.
  3. End the transaction:
    • by validating the operations performed (SQLTransaction(sqlCommit)).
    • by canceling the operations performed (SQLTransaction(sqlRollBack)).

Nesting transactions

Transactions can be nested.
Java Transactions cannot be nested. A WLanguage error occurs if a transaction is started while another transaction is in progress.

Locks and transactions

SQLTransaction does not lock data files or records. SQLTransaction begins, commits or rolls back a transaction.
If a transaction is started:
  • write operations in tables can cause deadlocks (e.g. in an HFSQL database, write operations lock records).
  • read operations can cause deadlocks on some databases if the isolation level is "repeatable-read" or "serializable" (note that this is not the case in HFSQL databases).
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)AjaxNative Connectors (Native Accesses)

Native MySQL Connector

SQLLock and SQLTransaction are used to manage locks and transactions only on "InnoDB" MySQL tables.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help