PreviousActiveX Controls Guide (v10) Next

Transaction

Chapter contents

Applies to:

VAccess

Description

The Transaction function controls Pervasive PSQL transaction processing within an application. It may be used to begin, end, or abort a Pervasive PSQL transaction.

Syntax

object.Transaction iOperationCode 
 

Part
Description
object
Required. The object placeholder represents an object expression that evaluates to an object in the Applies To list.
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.
iOperationCode
Required. Specifies the transaction operation to perform.

Remarks

Transaction processing is a data integrity feature of the Pervasive 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.

Code
Constant
Description
19
BTO_BeginTransaction
Begins an exclusive transaction - no other processes may access the files involved in the transaction until the transaction completes.
20
BTO_EndTransaction
Ends the transaction and commits changes which have been made to files since the transaction was begun.
21
BTO_AbortTransaction
Aborts all changes to files made since the Begin Transaction operation and ends the transaction.
1019
BTO_BeginTransaction + 1000
Begins a concurrent transaction (Pervasive.SQL version 6 or above- previous versions will return Status Code 1) Other processes may access the files affected by the transaction.

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	 

Chapter contents
Book contents

Prev topic: StepPreviousExtended
Next topic: Unlock