Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

SetSavePoint

Establish a savepoint.

Short Name

TRANSAV()

Type

Low-Level data file function

Declaration

COUNT SetSavePoint()

Description

SetSavePoint() creates a savepoint in the current transaction. When processing a complex transaction, you will find times when you want to back up just part way in that transaction. You do not want to use Commit(), as that commits, and ends, the entire transaction. You do not want to use Abort(), as that aborts the entire transaction.

To be able to reverse just a portion of a transaction, call SetSavePoint() to set a savepoint. There can be any number of savepoints within a transaction. SetSavePoint() returns a COUNT value that is the numerical representation of that save point. To roll back the transaction to a particular save point, issue a call to RestoreSavePoint(), passing the specific save point value as the parameter.

Return

SetSavePoint() returns the numerical representation of the save point. Use this value in a subsequent RestoreSavePoint() to reset the transaction to this save point. If an error occurs, SetSavePoint() returns zero. Check uerr_cod for the error value.

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

71

TNON_ERR

There is no active transaction pending.

94

PNDG_ERR

An update error occurred during one of the previous operations, but not cleared with RestoreSavePoint().

See c-tree Error Codes for a complete listing of valid c-tree error values.

Example

COUNT savepoint;


void domaster() {

Begin(ctENABLE|ctTRNLOG); /* start transaction with locks */

while(another()); { /* get next record to add */

savepoint = SetSavePoint();

/* get save point at beginning of each master record */

if (add_master() < 0)

Abort(); /* Abort if can't add master rec */

dodetail(); /* process detail records */

}

if (Commit(ctFREE)0)

printf("\nError %d in transaction",uerr_cod);

return;

}


void dodetail() {

while(moredetail()); { /*get next detail record to add */

if (add_detail()<0) { /* add details, if possible */

RestoreSavePoint(savepoint) /* with error, return to savept */

return;

}

}

}

See also

Abort(), AbortXtd(), Begin(), ClearSavePoint(), Commit(), RestoreSavePoint(), TRANRDY()

TOCIndex