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 Plus 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
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example COUNT savepoint;
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; }
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() |
||||||||||||