|
The Transaction function controls Pervasive.SQL transaction processing within an application. It may be used to begin, end, or abort a Pervasive.SQL transaction.
object.Transaction iOperationCode
Transaction processing is a data integrity feature of the Pervasive.SQL 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.
'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
Prev topic: StepPreviousExtended
|