Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

RestoreSavePoint

Undo transaction operations back to a savepoint.

Short Name

TRANRST()

Type

Low-Level data file function

Declaration

COUNT RestoreSavePoint(COUNT savpnt)

Description

RestoreSavePoint() rolls the current transaction back to a previously defined savepoint created with a call to SetSavePoint(). savpnt is the savepoint to roll back to, and is the value returned by the call to SetSavePoint(). This allows you to back up in a transaction to a particular point, without having to Abort() or Commit() the entire transaction. For a complete discussion of this process please see Data Integrity in the c-tree Programmer’s Reference Guide.

savpnt can also be specified as a small negative number. -1 means go back to the most current savepoint. -2 means go back one more, etc.

RestoreSavePoint() also clears errors that have occurred since the savepoint.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

71

TNON_ERR

There is no active transaction pending.

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(); /* RestoreSavePoint if can't add master rec */

dodetail(); /* process detail records */

}

if ( Commit(ctFREE) )

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(), SetSavePoint(), TRANRDY()

TOCIndex