다음을 통해 공유


ITransaction::Commit

Commits a transaction.

Syntax

HRESULT Commit(
   BOOL    fRetaining,
   DWORD   grfTC,
   DWORD   grfRM);

Parameters

  • fRetaining
    [in] Whether the commit 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.

  • grfTC
    [in] Values taken from the enumeration XACTTC. Values that may be specified in grfTC are as follows. These values are mutually exclusive.

    Flag

    Description

    XACTTC_ASYNC_PHASEONE

    When this flag is specified, an asynchronous commit is performed.

    XACTTC_SYNC_PHASEONE

    When this flag is specified, the call to ITransaction::Commit returns after phase one of the two-phase commit protocol.

    XACTTC_SYNC_PHASETWO

    When this flag is specified, the call to ITransaction::Commit returns after phase two of the two-phase commit protocol.

    XACTTC_SYNC

    Synonym for XACTTC_SYNC_PHASETWO.

  • grfRM
    [in] Must be zero.

Return Code

  • S_OK
    The transaction was successfully committed.

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

  • E_FAIL
    A provider-specific error occurred. The transaction was aborted.

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

  • XACT_E_ABORTED
    The transaction was implicitly aborted before ITransaction::Commit was called.

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

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

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

  • XACT_E_COMMITFAILED
    The transaction failed to commit for an unknown reason. The transaction was aborted.

  • XACT_E_CONNECTION_DOWN
    The connection to the transaction manager failed. The transaction was aborted.

  • 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
    Unable to commit the transaction because it had already been explicitly committed or aborted. This call was ignored.

  • XACT_E_NOTSUPPORTED
    An invalid combination of commit flags was specified, or grfRM was not equal to zero. This call was ignored.

Comments

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

DBPROP_COMMITPRESERVE

fRetaining

Rowset state after commit

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

If ITransaction::Commit fails for any reason that results in an aborted transaction, the session is left in auto-commit mode.

See Also

Reference

ITransaction::Abort