Partager via


ITransactionLocal::StartTransaction

Begins a new transaction.

Syntax

HRESULT StartTransaction (
   ISOLEVEL                isoLevel,
   ULONG                   isoFlags,
   ITransactionOptions    *pOtherOptions,
   ULONG                  *pulTransactionLevel);

Parameters

  • isoLevel
    [in] The isolation level to be used with this transaction. For more information, see Isolation Levels in OLE DB.

    Value

    Description

    ISOLATIONLEVEL_UNSPECIFIED

    Applicable only to ITransactionJoin::JoinTransaction. Invalid for ITransactionLocal or for setting isolation level while in auto-commit mode.

    ISOLATIONLEVEL_CHAOS

    Cannot overwrite the dirty data of other transactions at higher isolation levels.

    ISOLATIONLEVEL_READUNCOMMITTED

    Read Uncommitted.

    ISOLATIONLEVEL_BROWSE

    Synonym for ISOLATIONLEVEL_READUNCOMMITTED.

    ISOLATIONLEVEL_READCOMMITTED

    Read Committed.

    ISOLATIONLEVEL_CURSORSTABILITY

    Synonym for ISOLATIONLEVEL_READCOMMITTED.

    ISOLATIONLEVEL_REPEATABLEREAD

    Repeatable Read.

    ISOLATIONLEVEL_SERIALIZABLE

    Serializable.

    ISOLATIONLEVEL_ISOLATED

    Synonym for ISOLATIONLEVEL_SERIALIZABLE.

  • isoFlags
    [in] Must be zero.

  • pOtherOptions
    [in] Optionally a null pointer. If this is not a null pointer, it is a pointer to an object previously returned from ITransactionLocal::GetOptionsObject called on this session instance.

  • pulTransactionLevel
    [out] A pointer to memory in which to return the level of the new transaction. The value of the top-level transaction is 1. If pulTransactionLevel is a null pointer, the level is not returned.

Return Code

  • S_OK
    The method succeeded.

  • DB_E_OBJECTOPEN
    A rowset object was open, and the provider does not support starting a new transaction with existing open rowset objects.

  • E_FAIL
    A provider-specific error occurred.

  • E_UNEXPECTED
    An unknown error occurred, and the method failed.

  • XACT_E_CONNECTION_DENIED
    This session could not create a new transaction at the present time due to unspecified capacity issues.

  • XACT_E_CONNECTION_DOWN
    This session is having communication difficulties with its internal implementation.

  • XACT_E_ISOLATIONLEVEL
    Neither the requested isolation level nor a strengthening of it can be supported by this transaction implementation, or isoLevel was not valid.

  • XACT_E_LOGFULL
    A transaction could not be created because this session specifies logging to a device that lacks available space.

  • XACT_E_NOISORETAIN
    The requested semantics of retention of isolation across retaining commit and abort boundaries cannot be supported by this transaction implementation, or isoFlags was not equal to zero.

  • XACT_E_NOTIMEOUT
    A noninfinite time-out value was requested, but time-outs are not supported by this transaction.

  • XACT_E_XTIONEXISTS
    This session can handle only one extant transaction at a time, and there is presently such a transaction.

    The session supports a limited number of nested transactions, and that limit has been reached.

Comments

ITransactionLocal::StartTransaction starts a new local transaction. If there is already an active transaction on the session (that is, StartTransaction has been called with no matching ITransaction::Commit or ITransaction::Abort), the new transaction is started as a nested transaction below the current transaction. Calling ITransaction::Commit or ITransaction::Abort always commits or aborts the transaction at the lowest level, respectively. If the provider does not support nested transactions, calling ITransactionLocal::StartTransaction when there is already an active transaction on the session returns XACT_E_XTIONEXISTS.

See Also

Reference

ITransactionOptions::SetOptions