AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / Funciones SQL
  • Example 1: Transaction of a database opened by SQLConnect
  • Example 2: Changing the database name (OLE DB)
SQLTransaction (Example)
Example 1: Transaction of a database opened by SQLConnect
Reportes y ConsultasOLE DB The following example is used to perform operations in a transaction during an access to a database performed by SQLConnect. The transaction is then rolled back: the operations are not recorded in the data file.
ConnectionNum is int = SQLConnect("MyDatabase", "User", "Password", "", "OLEDB", "MyProvider")
IF ConnectionNum = 0 THEN
   	SQLInfo()
   	Error("Error while opening the connection:" + SQL.MesError)
ELSE
   	// Put the connection in transaction
   	SQLTransaction(sqlStart)
   	// Modify the value of all the AFile.AnItem items
   	IF SQLExec("UPDATE AFile SET AnItem = 'new value'", "UpdateQuery") = 0 THEN
      		SQLInfo("UpdateQuery")
      		Error("Error while running the query:" + SQL.MesError)
      		SQLTransaction(sqlCommit)
  	END
  	// Roll back transaction
  	SQLTransaction(sqlRollBack)
  	// The content of AFile did not change
END
Example 2: Changing the database name (OLE DB)
Reportes y ConsultasOLE DB The following example is used to perform operations in a transaction during an access to a data file that uses a connection described in the analysis.
The transaction is then rolled back: the operations are not recorded in the data file.
In this example, AFile is an OLE DB data file described in the data model editor. This data file uses the connection named MyConnection described in the data model editor.
HReadFirst(AFile)
// Put the connection in transaction
SQLTransaction(sqlStart, MyConnection)
// Modify the value of the item
AFile.AnItem = "new item"
HModify(AFile)
// Roll back transaction
SQLTransaction(sqlRollBack, MyConnection)
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local