Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ClearTranError

Clear an error in an active transaction

DEPRECATED

(circa 2008) It was determined that the TRANCLR() function is unsafe to use: it simply clears the pending transaction error flag and does not do the work needed to clean up a failed operation such as restoring to a savepoint or aborting a transaction does. For this reason, TRANCLR() returns NSUP_ERR without clearing the pending transaction error flag.

Applications that use TRANCLR() should instead recover from an error in a transaction by using savepoints or aborting and restarting the transaction.

This function will be completely removed in future releases.

DEPRECATED - Consider the use of formal Savepoints instead.

Short Name

TRANCLR()

Type

Low-level function

Declaration

COUNT ClearTranError()

Description

If an update error occurs when you are in the middle of a transaction, you will not be able to commit that transaction. For example, AddRecord() could fail trying to add a duplicate key where they are not allowed. A subsequent call to Commit() fails, since an error has occurred.

The proper way to handle this situation is to either use RestoreSavePoint() to go back to a savepoint, or to abandon the entire transaction with Abort(). There is an alternative, however. ClearTranError() can clear the error flag, allowing you to continue with the transaction after correcting the previous error. Typically, you will only do this if you are working with low-level update functions and you know how to recover from the error that has occurred. We DO NOT recommend this, however, as you are now responsible for the integrity of your data.

Return

ClearTranError() always returns zero (NO_ERROR).

Example

COUNT invfil;

struct invd { TEXT delflg; LONG part_no; } recbuf;


part_no = getpartno();

recbuf.delflg = '\0'; /* clear delete flag */

if (AddRecord(invfil,&recbuf))

ClearTranError();

See also

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

TOCIndex