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 / HFSQL / Gestión de transacciones / Funciones WLanguage
  • Error cases
  • Handling records during a transaction
  • 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
Validates the current transaction:
  • the modifications performed on the data file since the start of transaction (HTransactionStart or HTransaction) are validated.
  • the transaction file is deleted (if this transaction is the last transaction in progress for a network application).
  • the records locked in read-only by the transaction are unlocked.
Ejemplo
MyConnection1 is Connection
// Start transaction on data files associated with MyConnection1
HTransactionStart(MyConnection1)
// Code used to prepare the order to added
// ...
WHEN EXCEPTION IN
	// Add the order
	HAdd(Orders) 
	// Validate the addition
	HTransactionEnd(MyConnection1)
DO
	// Delete the order lines
	HTransactionCancel(MyConnection1)
END
// Start transaction on the Orders and OrdLine data files
HTransactionStart("C:\Temp\Transaction.trs", "Orders,OrdLine,-Customer")
 
// Code used to prepare the order to added
// ...
 
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd()
DO
// Delete the order lines
HTransactionCancel()
END
Sintaxis

Validating a transaction in progress on a connection Ocultar los detalles

<Result> = HTransactionEnd(<Connection>)
<Result>: Boolean
  • True if the transaction is ended,
  • False if a problem occurs. HErrorInfo returns more details about the error.
Caution: If a global transaction is started, the function does nothing.. The syntax 2 must be used.
<Connection>: Character string or Connection variable
Connection to use. This connection corresponds to: If this parameter corresponds to the hAccessHF7 constant, the transaction will be performed on ISAM HFSQL data files.

Validating a global transaction in progress Ocultar los detalles

<Result> = HTransactionEnd()
<Result>: Boolean
  • True if the transaction is ended,
  • False if a problem occurs. HErrorInfo returns more details about the error.
Observaciones

Error cases

  • Transaction nesting: it is not possible to nest transactions (i.e. to call function HTransactionStart or function HTransaction 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 HTransactionStart (or HTransaction) to start a transaction in the new context.
WINDEVOLE DBConectores Nativos

OLE DB and Native Connectors

Only syntaxes with connection are taken into account by the Native Connectors (also called Native Accesses) that support transactions. You can also use SQLTransaction.
Componente: wd300hf.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Example in doc correcton
When using Transaction commands Start, End and Cancel always include the connection or source used in the Start in the associated End and Cancel

TransactionStart(MyConnection)

Hadd(Customer)
if ErrorOccurred() then
TransactionCancel(MyConnection)
ELSE
TransactionEnd(MyConnection)
END
CCordes
03 10 2019
Example Transaction with commit 100 in 100
//SQL

SERIAL is int

HTransactionStart(Hfsql)

FOR EACH t0010_enderecoscorreios //leitura da tabela ms sql server // TABELA DE ORIGEM

SERIAL += 1

PROGBAR_01..Value += 1
IF PROGBAR_01..Value = 100 THEN
HTransactionEnd(Hfsql) //commit
PROGBAR_01..Value = 0
HTransactionStart(Hfsql) //start
Multitask(1) //permite compartilhar o processador com os outros prog e serviços windows
END

//HFSQL = MS SQL SERVER 2016 / DEVELOPER
enderecoscorreios.LogradouroAbrev = t0010_enderecoscorreios.LogradouroAbrev
enderecoscorreios.Logradouro = t0010_enderecoscorreios.Logradouro

ok is boolean = HAdd(enderecoscorreios) // gravacao no hfsql
IF ok = False THEN
HTransactionCancel(Hfsql) //Rollback
END

END

Info(SERIAL)
BOLLER
13 04 2017

Última modificación: 27/03/2025

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