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 mode parameter can take on values from the following table.
Mode |
Description |
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 (94) error and aborts the transaction.
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(). |
See c-tree Plus Error Codes 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
Abort, AbortXtd, Begin, ClearSavePoint, RestoreSavePoint, SetSavePoint, TRANRDY
For a full description of transaction processing, see the Data Integrity in the c-tree Plus Programmer’s Reference Guide.