isc_rollback_transaction()

From InterBase

Go Up to API Function Reference


Undoes changes made by a transaction, and restores the database to its state prior to the start of the specified transaction.

Syntax

 ISC_STATUS isc_rollback_transaction(
 ISC_STATUS *status_vector,
 isc_tr_handle *trans_handle);
Parameter Type Description

status_vector

ISC_STATUS *

Pointer to the error status vector

trans_handle

isc_tr_handle *

Pointer to a transaction handle whose value has been set by a previous isc_start_transaction() call; trans_handle returns an error if NULL.

Description

isc_rollback_transaction() rolls back a specified transaction, closes record streams, frees system resources, and sets the transaction handle to zero. It is typically used to undo all database changes made by a transaction when an error occurs.

A call to this function can fail only if:

  • You pass a NULL or invalid transaction handle.
  • The transaction dealt with more than one database and a communications link fails during the rollback operation. If that happens, subtransactions on the remote node will end up in limbo. You must use the database maintenance utility to manually roll back those transactions.

Example

The following call rolls back a transaction:

isc_rollback_transaction(status_vector, &trans);

Return value

isc_rollback_transaction() returns the second element of the status vector. Zero indicates success. A nonzero value indicates an error. For InterBase errors, the first element of the status vector is set to 1, and the second element is set to an InterBase error code.

To check for an InterBase error, examine the first two elements of the status vector directly. For more information about examining the status vector, see Handling Error Conditions.

See Also

Advance To: