PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Network application (ISAM database)
  • Locking records
  • Error cases
  • Temporary files created during the transaction (ISAM database)
  • Handling records during a transaction
  • Transactions and independent HFSQL context
  • OLE DB and Native Accesses
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Starts a transaction on the data files (HFSQL or accessed via Native Access) and creates the file of transactions.
What information is saved in the transaction file? Whenever a WLanguage function modifies a data file or an index file during a transaction, the former values of the record and the operation performed are stored in the transaction file.
HFSQL Client/Server This function starts both a HFSQL Classic transaction (ISAM) and a HFSQL Client/Server transaction.
HFSQL Client/Server This function proposes two operating modes of transactions:
  • Versions 19 and later
    The transaction can be started on a connection: in this case, only the files associated with this connection are put in transaction. This mode is required to manage the isolation levels of transactions.
    New in version 19
    The transaction can be started on a connection: in this case, only the files associated with this connection are put in transaction. This mode is required to manage the isolation levels of transactions.
    The transaction can be started on a connection: in this case, only the files associated with this connection are put in transaction. This mode is required to manage the isolation levels of transactions.
  • The transaction can be started on all HFSQL connections (existing ones or future ones). In this case, HTransactionStart starts both a HFSQL Classic transaction (ISAM) and a HFSQL Client/Server transaction.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
AndroidAndroid Widget iPhone/iPadWindows Mobile The management of transactions is available for the HFSQL Client/Server databases.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Java This function is now available for the Java applications.
Android This function is now available for the Android applications.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Java This function is now available for the Java applications.
Android This function is now available for the Android applications.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Java This function is now available for the Java applications.
Android This function is now available for the Android applications.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Versions 23 and later
Note: This function is equivalent to HTransaction.
New in version 23
Note: This function is equivalent to HTransaction.
Note: This function is equivalent to HTransaction.
Example
Versions 19 and later
// Start the transaction on the files associated with MyConnection1
HTransactionStart(MyConnection1)
Add_Order()
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd(MyConnection1)
DO
// Delete the order lines
HTransactionCancel(MyConnection1)
END
New in version 19
// Start the transaction on the files associated with MyConnection1
HTransactionStart(MyConnection1)
Add_Order()
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd(MyConnection1)
DO
// Delete the order lines
HTransactionCancel(MyConnection1)
END
// Start the transaction on the files associated with MyConnection1
HTransactionStart(MyConnection1)
Add_Order()
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd(MyConnection1)
DO
// Delete the order lines
HTransactionCancel(MyConnection1)
END
// Start the transaction on the Orders and OrdLine files
HTransactionStart("C:\Temp\Transaction.trs", "Orders,OrdLine,-Customer")
Add_Order()
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd()
DO
// Delete the order lines
HTransactionCancel()
END
Syntax
Versions 19 and later
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection Hide the details

<Result> = HTransactionStart(<Connection Name> [, <List of Files>])
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<List of Files>: Optional character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
New in version 19
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection Hide the details

<Result> = HTransactionStart(<Connection Name> [, <List of Files>])
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<List of Files>: Optional character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection Hide the details

<Result> = HTransactionStart(<Connection Name> [, <List of Files>])
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<List of Files>: Optional character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
Versions 19 and later
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection or an ISAM transaction Hide the details

<Result> = HTransactionStart(<Connection Name> , <Name of Transaction File> , <List of Files>)
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • Empty string ("") or hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<Name of Transaction File>: Character string (with quotes)
HFSQL Full name of transaction file (used to store the operations performed in transaction). This file will be automatically deleted when using HTransactionEnd or HTransactionCancel.
If this name corresponds to an empty string, the transaction file will be created in the directory of application files and it will be named: <Project Name>_$TRS_OPERATION.TRS.
HFSQL Client/ServerOLE DBNative Accesses This parameter is ignored. This parameter is taken into account for the HFSQL Classic transactions only (ISAM transactions).
<List of Files>: Character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
New in version 19
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection or an ISAM transaction Hide the details

<Result> = HTransactionStart(<Connection Name> , <Name of Transaction File> , <List of Files>)
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • Empty string ("") or hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<Name of Transaction File>: Character string (with quotes)
HFSQL Full name of transaction file (used to store the operations performed in transaction). This file will be automatically deleted when using HTransactionEnd or HTransactionCancel.
If this name corresponds to an empty string, the transaction file will be created in the directory of application files and it will be named: <Project Name>_$TRS_OPERATION.TRS.
HFSQL Client/ServerOLE DBNative Accesses This parameter is ignored. This parameter is taken into account for the HFSQL Classic transactions only (ISAM transactions).
<List of Files>: Character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.
AndroidAndroid Widget Java This syntax is not available in Android, Android Widget and Java.

Starting a Client/Server transaction on a specific connection or an ISAM transaction Hide the details

<Result> = HTransactionStart(<Connection Name> , <Name of Transaction File> , <List of Files>)
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Connection Name>: Character string (with or without quotes)
  • Name of connection to use. This connection was defined:
  • Empty string ("") or hAccessHF7 constant: The transaction is performed on the ISAM HFSQL files.
<Name of Transaction File>: Character string (with quotes)
HFSQL Full name of transaction file (used to store the operations performed in transaction). This file will be automatically deleted when using HTransactionEnd or HTransactionCancel.
If this name corresponds to an empty string, the transaction file will be created in the directory of application files and it will be named: <Project Name>_$TRS_OPERATION.TRS.
HFSQL Client/ServerOLE DBNative Accesses This parameter is ignored. This parameter is taken into account for the HFSQL Classic transactions only (ISAM transactions).
<List of Files>: Character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
OLE DBNative Accesses This parameter is ignored. All the data files associated with the connection are in transaction on the native server.

Starting an ISAM and/or Client/Server transaction on all the HFSQL Client/Server connections (existing ones or future ones) Hide the details

<Result> = HTransactionStart([<Name of Transaction File> [, <List of Files>]])
<Result>: Boolean
  • True if the transaction was started,
  • False if a problem occurred. HErrorInfo returns more details about the error.
<Name of Transaction File>: Optional character string (with quotes)
HFSQL Full name of transaction file (used to store the operations performed in transaction). This file will be automatically deleted when using HTransactionEnd or HTransactionCancel.
If this name is not specified or if it corresponds to an empty string, the transaction file will be created in the directory of the data files of the application and it will be named: <Project Name>_$TRS_OPERATION.TRS.
HFSQL Client/ServerOLE DBNative Accesses This parameter is ignored. This parameter is taken into account for the HFSQL Classic transactions only (ISAM transactions).
<List of Files>: Optional character string (with quotes)
List of logical names of one or more files to take into account (or not) in the transaction (in this case, the file name is preceded by the "-" sign).
If this parameter is not specifiedAll the files used during the transaction will be taken into account in the transaction.
If all the files are prefixed by the "-" sign
For example: "-Customer, -Product"
All the files specified in the list and used during the transaction will not be taken into account by the transaction.
All the files not specified in the list will be taken into account and used during the transaction.
If no file in the list is prefixed by the "-" sign
For example: "Customer, Product"
All the files specified in the list and used during the transaction will be taken into account by the transaction.
All the files not specified in the list and used during the transaction will not be taken into account by the transaction.
If some files are prefixed by "-" and others are not
For example: "-Customer, Product" (equivalent to "Product")
All the files in the list prefixed by "-" and used during the transaction will not be taken into account by the transaction.
All the files in the list not prefixed by "-" and used during the transaction will be taken into account by the transaction.
The files not specified in the list will be excluded from the transaction
Remarks
WINDEVWEBDEV - Server codeReports and QueriesAjaxUser code (UMC)HFSQL

Network application (ISAM database)

In network, the transaction file can be created on a local disk or on a network drive.
  • If the transaction file is installed on a local computer, this file will contain information regarding the transactions performed by the current computer. In this case, the transaction file is deleted when the transaction is ended.
  • If the transaction file is installed on a network drive (recommended), this file will contain information regarding the transactions performed by several computers. Each computer is identified by a unique number. In this case, the transaction file is deleted when the last transaction is ended.

Locking records

The added, modified or deleted records in a transaction are locked in write mode.

Error cases

  • Nesting transactions: The transactions cannot be nested (HTransactionStart cannot be called in a transaction). In this case, the error 70031 occurs.
  • Versions 19 and later
    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 mode is not "Read Uncommitted".
    New in version 19
    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 mode is not "Read Uncommitted".
    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 mode is not "Read Uncommitted".
WINDEVWEBDEV - Server codeReports and QueriesAjaxUser code (UMC)HFSQL

Temporary files created during the transaction (ISAM database)

During the transaction, temporary files (".TRX" extension) are created in the directory containing the data files (".FIC" files). These temporary files must not be deleted. Otherwise, the data handled by the transaction could be damaged.
Note: These temporary files are automatically deleted at the end of the transaction.

Handling records during a transaction

During a transaction, some rules must be complied with when handling the records. See Transactions: Handling records during a transaction for more details.

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 to start a transaction in the new context.
WINDEVWEBDEV - Server codeAjaxUser code (UMC)OLE DBNative Accesses

OLE DB and Native Accesses

HTransactionStart cannot be used in this version. To start a transaction, use SQLTransaction.Only the syntaxes with connection are taken into account by the Native Accesses that support the transactions. You also have the ability to use SQLTransaction.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Windows Mobile wp230hf.dll
Java wd230java.jar
Linux wd230hf.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
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
Apr. 13 2017