Database Engines:ads

Transaction processing Professional

When an Xbase++ application accesses database files via the ADSDBE, it can take advantage of the transaction processing system (TPS) implemented in the ADS. The term "transaction" describes a series of insert, update or delete operations that must be applied to multiple records by the database server. This can affect one or more database files. To ensure the data integrity, however, the database server must guarantee that either all records participating in a transaction are updated or none of them. In addition the application must be able to detect whether or not a transaction was interrupted due to a file server break down. A technical defect can lead to the situation where a transaction is only half complete which, in turn, can affect the data integrity of an entire database. The ADS can cope with such a situation by "undoing" incomplete transactions (roll back), thus leaving a database in its pre-transactional state.

The ADS transaction processing system assures a high level of data integrity and can be used in an Xbase++ application by a DacSession object. The basic steps are as follows:

oSession := DacSession():new( "DBE=ADSDBE;SERVER=\\ALASKA\VOL1" ) 

USE \\ALASKA\VOL1\DATA\FileA NEW 
USE \\ALASKA\VOL1\DATA\FileB NEW 

SELECT FileA 
Rlock() 
SELECT FileB 
RLock() 

oSession:beginTransaction() 

REPLACE FileA->FIELD_A WITH "AAA" 
REPLACE FileB->FIELD_B WITH "BBB" 

oSession:commitTransaction() 

FileA->( DbUnlock() ) 
FileB->( DbUnlock() ) 

The ADS TPS requires records participating in a transaction to be locked prior to opening the transaction context. When a client has obtained the record locks, the method :beginTransaction() of the DacSession object is executed which marks the begin of the transaction. All consecutive insert, update and delete operations (APPEND, REPLACE and DELETE commands) are going to be considered as being part of the transaction. Within the transaction context, the requested changes are "recorded" by the ADS and applied to the database files when the transaction context is closed with :commitTransaction(). Only this way, the changes become visible to other client stations.

When using transactions, concurrent access to table and/or index files by-passing the ADS server is not allowed. Doing so will lead to data and/or index corruption. If the ADS TPS is used, common data can only shared via the ADS server.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.