Working with Transactions
Go Up to API Guide
This chapter describes how to perform the following actions:
- Set up a transaction parameter buffer (TPB) that contains parameters
- Set up and initialize transaction handles
- Use the API functions that control transactions
- Retrieve a transaction ID
Each data definition and data manipulation in an application takes place in the context of a transaction: one or more statements that work together to complete a specific set of actions that must be treated as an atomic unit of work.
InterBase allows a connection to open more than one transaction at a time. These simultaneous transactions are independent of each other, and can conflict. Multiple concurrent transactions within a connection are useful for applications that use a database in several independent ways.
The following table summarizes the API functions most commonly used when working with transactions. Functions are listed in the order they typically appear in an application.
Function | Purpose |
---|---|
|
Starts a new transaction against one or more databases; use a previously declared and populated TPB. |
|
Commits changes of a transaction, and preserves the transaction context for further transaction processing. |
|
Commits changes of a transaction, and ends the transaction |
|
This is used to send in a starting transaction ID when creating or restoring a database. This transaction ID can be as large as a 64-bit Integer type.
|
|
Rolls back changes of a transaction, and ends the transaction. |
|
This is for Services API; it has a similar function as isc_dpb_transaction but it is not as flexible. It requires an int64 data type value only.
|
In addition to these functions, the following table lists less frequently used API transaction functions in the order they typically appear when used:
Function | Purpose |
---|---|
|
Starts a new transaction against one or more databases; used instead of |
|
Performs the first phase of a two-phase commit, prior to calling |
|
Performs the first phase of a two-phase commit, prior to calling |
|
Rolls back changes of a transaction but maintains transaction context. |