Compartilhar via


ITransaction::Abort

Aborts a transaction.

Syntax

HRESULT Abort(
   BOID    *pboidReason,
   BOOL     fRetaining,
   BOOL     fAsync);

Parameters

  • pboidReason
    [in] A pointer to a BOID that indicates why the transaction is being aborted. If this is a null pointer, no reason is provided.

  • fRetaining
    [in] Whether the abort is retaining or nonretaining.

    Note

    A retaining commit or abort should not change the characteristics (isolation level, isolation flags, transaction options) of the transaction. The new unit of work retains the same characteristics as the committed work.

  • fAsync
    [in] When fAsync is TRUE, an asynchronous abort is performed and the caller must use ITransactionOutcomeEvents to learn the outcome of the transaction.

Return Code

  • S_OK
    The transaction was successfully aborted.

  • XACT_S_ABORTING
    An abort operation was already in progress. This call was ignored.

  • XACT_S_ASYNC
    An asynchronous abort was specified. The abort operation has begun, but its outcome is not yet known. When the transaction is complete, notification will be sent by ITransactionOutcomeEvents.

  • E_FAIL
    The transaction failed to abort for an unspecified reason.

  • E_UNEXPECTED
    An unexpected error occurred. The transaction status is unknown.

  • XACT_E_ALREADYINPROGRESS
    A commit operation was already in progress. This call was ignored.

  • XACT_E_CANTRETAIN
    A retaining abort is not supported, or a new unit of work could not be created. The abort succeeded, and the session is in auto-commit mode.

    Abort was called on a distributed transaction with fRetaining set to TRUE.

  • XACT_E_CONNECTION_DOWN
    The connection to the transaction manager failed. The transaction state is unknown.

  • XACT_E_INDOUBT
    The transaction status is in doubt. A communication failure occurred, or a transaction manager or resource manager has failed.

  • XACT_E_NOTRANSACTION
    The transaction cannot be aborted because it already had been implicitly or explicitly committed or aborted. This call was ignored.

  • XACT_E_NOTSUPPORTED
    fAsync was TRUE on input, and asynchronous abort operations are not supported.

Comments

The following table shows how the values of fRetaining and DBPROP_ABORTPRESERVE affect the rowset state and transaction mode.

DBPROP_ABORTPRESERVE

fRetaining

Rowset state after abort

Resulting transaction mode of session

FALSE

FALSE

zombie

implicit/auto-commit

FALSE

TRUE

zombie

explicit/manual-commit

TRUE

FALSE

preserved

implicit/auto-commit

TRUE

TRUE

preserved

explicit/manual-commit

See Also

Reference

ITransaction::Commit