AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • Location and access to data files
  • Detecting an error
  • Tip: Restoring the consistency of the database
  • Error cases
  • Transactions and independent HFSQL context
  • OLE DB and Native Connectors
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
If a transaction is in progressrolls back all operations performed on data files in transactions since the start of the transaction. In this case, the transaction is canceled without interrupting the program execution.
If no transaction is in progressrestores database consistency and rolls back a failed transaction (e.g. in the event of a power failure).
Note: A failed transaction can be rolled back by any program..
The transaction file is automatically destroyed if it is not shared. The records locked by the write operations performed during the transaction are unlocked.
Note The <Source>.TransactionFree function transforms all records "in transaction" into "normal" records if they do not belong to a transaction currently in progress.
AndroidWidget Android iPhone/iPadIOS WidgetMac Catalyst The management of transactions is available for HFSQL Client/Server databases.
Ejemplo
MaConnexion is Connection

// Début de la transaction sur les fichiers de données associés à la connexion MaConnexion
MaConnexion.TransactionDébut()
Ajout_Commande()
WHEN EXCEPTION IN
	// Ajout de la commande
	Commande.Ajoute() 
	// Validation de l'ajout
	MaConnexion.TransactionFin()
DO
	// Suppression des lignes de commandes
	MaConnexion.TransactionAnnule()
END
Sintaxis

Cancelar una transacción en curso o una transacción interrumpida en una conexión Client/Server Ocultar los detalles

<Result> = <Connection>.TransactionCancel()
<Result>: Booleano
  • True if the transaction was canceled,
  • False if a problem occurs. HErrorInfo returns more details about the error.
Caution:
  • If a transaction is in progress on the connection, it is canceled.
  • If no transaction is in progress, the interrupted transactions are canceled for the specified connection.
<Connection>: Variable de tipo Connection
Name of the Connection variable that describes the connection to use.

Cancelar una transacción interrumpida en una base de datos Client/Server (se debe utilizar si no hay ninguna transacción en curso) Ocultar los detalles

<Result> = <Connection>.TransactionCancel(<Database>)
<Result>: Booleano
  • True if the transaction was canceled,
  • False if a problem occurs. HErrorInfo returns more details about the error.
Caution:
  • Only the interrupted transactions on the specified database are canceled.
  • The transactions in progress are not canceled.
<Connection>: Variable de tipo Connection
Name of the Connection variable that describes the connection to use.
<Database>: Cadena de caracteres
Name of the relevant database. An error occurs if this parameter corresponds to an empty string ("").

Cancelar una transacción específica, relacionada con una conexión Ocultar los detalles

<Result> = <Connection>.TransactionCancel(<Transaction to cancel>)
<Result>: Booleano
  • True if the transaction was canceled,
  • False if a problem occurs. HErrorInfo returns more details about the error.
Warning: Only interrupted transactions on the specified database are rolled back.
<Connection>: Variable de tipo Connection
Name of the Connection variable that describes the connection to use.
<Transaction to cancel>: Entero
Identifier of transaction that will be canceled for the specified connection. This identifier is returned by <Connection variable>.TransactionList.
Observaciones

Location and access to data files

Before calling <Connection variable>.TransactionCancel, the data files handled by the canceled transaction must be:

Detecting an error

When an error is detected by the program (management of errors with WHILE EXCEPTION for example), <Connection variable>.TransactionCancel is used to:

Tip: Restoring the consistency of the database

If a breakdown (power outage, reboot, ...) occurs during a transaction, the data files may become corrupted: the transaction was neither validated nor canceled. The transaction file is still found on the computer.
To restore the consistency of the database, you should propose in your application:
Note: this operation can take a relatively long time (depending on the number of transactions performed).

Error cases

  • Transaction nesting: it is not possible to nest transactions (i.e. to call function <variable Connection>.TransactionStart or function <Variable Connection>.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".

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 <variable Connection>.TransactionStart (or <Variable Connection>.Transaction) to start a transaction in the new context.
WINDEVWEBDEV - Código ServidorCódigo de Usuario (UMC)AjaxOLE DBConectores Nativos

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.
Componente: wd300hf.dll
Versión mínima requerida
  • Versión 25
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 04/12/2024

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