Transaction
Applies to
VAccess
Description
The Transaction function controls PSQL transaction processing within an application. It may be used to begin, end, or abort a PSQL transaction.
Syntax
object.Transaction iOperationCode
The syntax for this method has the following parts:
 
Note: This placeholder is simply a requirement of ActiveX architecture, and does not limit the scope of the transaction to the file attached to object. Any inserts, updates, or deletes to any files nested between the begin and end transaction methods will be included in the transaction.
Remarks
Transaction processing is a data integrity feature of the PSQL record manager. Its purpose is to insure that, in a set of related updates to different tables, either all of the updates succeed, or all of them are rolled back so that relational integrity is maintained.
The following operations are supported by the Transaction method. Any operation codes not listed here will return a Status Code 1, invalid operation.
 
Constant declarations are included in the files GLOBAL.BAS (for 16 bit Visual Basic), GLOBAL.BAS (for Visual Basic), GLOBAL.PAS (for Delphi), and GLOBAL.H (for Visual C++). Include one of these files (whichever is appropriate for your development environment) in your project to use the Transaction constants in your application.
Example
'Begin a concurrent transaction
status% = Customers.Transaction(BTO_BeginTransaction + 1000)
 
If status% = 0 Then
'BeginTransaction succeeded,
'Add the order record
status% = status% + Orders.Insert
 
'Add the billing record
status% = status% + Invoices.Insert
 
'Get the customer record and modify it
Customers.IndexNumber = 1 'custID
Customers.FieldValue("custID") = _ Invoices.FieldValue("custID")
status% = status% + Customers.GetEqual
Customers.FieldValue("lastInvoiceDate") = _ Invoices.FieldValue("InvoiceDate")

balance = Customers.FieldValue("balance") + _ Invoice.FieldValue("amount")
Customers.FieldValue("balance") = balance
status% = status% + Customers.Update
End If
 
If status% = 0 Then
'All changes succeeded. Commit the transaction.
Customers.Transaction(BTO_EndTransaction)
Else
'One or more inserts failed. Abort the transaction.
Customers.Transaction(BTO_AbortTransaction)
End If