FairCom Corporation


F.24 Commit


Commit the current transaction in progress.

Short Name

TRANEND

TYPE

Low-level data file function

DECLARATION

COUNT Commit(COUNT mode)

DESCRIPTION

Commits all file updates for files that support transactions, which means that the updates go to the data files from the preimage buffers.

The parameter mode can be one of the following:

ctFREE
Clear the LockISAM state and free all locks acquired before and during an active transaction.
ctKEEP
Does not clear the LockISAM state and keeps all the locks acquired before and during an active transaction.
ctKEEP_OUT
Release only locks obtained within the transaction and/or locks on records updated within the transaction. Does not clear the LockISAM state.
ctKEEP_OUT_ALL
Unconditionally keep all locks that were acquired before the transaction began. Free locks obtained within the transaction. Does not clear the LockISAM state.

Note: If an update error has occurred, such as an AddRecord failing due to a duplicate key, Commit returns a PNDG_ERR error and aborts the transaction. The error condition can be cleared prior to the call to Commit with a call to ClearTranError, at the great risk of corrupting data, or by backing up to a savepoint set with RestoreSavePoint before the error occurred.

RETURN

Value
Symbolic Constant
Explanation
0
NO_ERROR
No error occurred.
37
WRITE_ERR
Most likely the disk is full. Transaction is aborted.
71
TNON_ERR
There is no active transaction pending.
94
PNDG_ERR
An update error occurred during one of the previous operations that has not been cleared through RestoreSavePoint or ClearTranError.

See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

EXAMPLE

Begin(ctENABLE|ctTRNLOG); /* Start transaction with locks */
while(another()) /* Get next record to add */
{
if (add_master() < 0) {
printf(Error adding record.\n");
Abort(); /* Abort if can't add master rec. */
return(-1);
}
dodetail(); /* Process detail records */
}
if (Commit(ctFREE) > 0)
printf("\nError %d in transaction",uerr_cod);

SEE ALSO

Begin, Abort, ClearTranError, SetSavePoint, and RestoreSavePoint. For a full description of transaction processing, see the Chapter 13 "Data Integrity" of the c-tree Plus Programmer's Reference Guide.


FairCom Corporation
www.faircom.com