OracleLogicalTransaction Class

The OracleLogicalTransaction class provides detailed information about the logical transaction status. Applications can conclusively determine the outcome of the running transaction during the last database outage, then act accordingly to commit, complete, or rollback the transaction.

Class Inheritance

System.Object

  System.MarshalByRefObject

    Oracle.DataAccess.Client.OracleLogicalTransaction

Declaration

// C#
public sealed class OracleLogicalTransaction

Requirements

Provider ODP.NET, Unmanaged Driver ODP.NET, Managed Driver
Assembly Oracle.DataAccess.dll Oracle.ManagedDataAccess.dll
Namespace Oracle.DataAccess.Client Oracle.ManagedDataAccess.Client
.NET Framework 3.5, 4.0, 4.5, 4.6 4.0, 4.5, 4.6

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

OracleLogicalTransaction Members

OracleLogicalTransaction members are listed in the following tables.

OracleLogicalTransaction Public Read-Only Properties

OracleLoigcalTransaction public read-only properties are listed in Table 6-89

Table 6-89 OracleLogicalTransaction Public Read-Only Properties

Property Description

Committed

Specifies if the transaction was committed or not

ConnectionString

Specifies a subset of the connection string used for the transaction running during the last database outage

DataSource

Specifies the data source, for example TNS alias, that is associated with the connection from which this object was obtained from

This property has been deprecated in 12.1.0.2. It will be desupported in a future release.

LogicalTransactionId

The logical transaction id is used to determine the commit outcome of the last transaction open in a database session following an outage.

UserCallCompleted

Specifies if the transaction completed and that the information returned may be incomplete and/or not all expected work was completed

UserId

Specifies the user ID that is associated with the connection from which this object was obtained from

This property has been deprecated in 12.1.0.2. It will be desupported in a future release.


OracleLogicalTransaction Methods

OracleLoigcalTransaction methods are listed in Table 6-90

Table 6-90 OracleLogicalTransaction Methods

Property Description

Dispose

This method releases any resources or memory allocated by the object

GetOutcome

This method retrieves the transaction outcome from the database server. The method will determine whether the transaction committed and completed or not.


OracleLogicalTransaction Public Read-Only Properties

OracleLoigcalTransaction public read-only properties are listed in Table 6-91

Table 6-91 OracleLogicalTransaction Public Read-Only Properties

Property Description

Committed

Specifies if the transaction was committed or not

ConnectionString

Specifies a subset of the connection string used for the transaction running during the last database outage

DataSource

Specifies the datasource, for example TNS alias, that is associated with the connection from which this object was obtained from

This property has been deprecated in 12.1.0.2. It will be desupported in a future release.

LogicalTransactionId

The logical transaction id is used to determine the commit outcome of the last transaction open in a database session following an outage.

UserCallCompleted

Specifies if the transaction completed and that the information returned may be incomplete and/or not all expected work was completed

UserId

Specifies the user ID that is associated with the connection from which this object was obtained from

This property has been deprecated in 12.1.0.2. It will be desupported in a future release.


Committed

This property specifies if the transaction was committed or not.

Declaration

// C#
public bool? Committed {get;}

Property Value

bool.

Remarks

If GetOutcome() is not called, the this property holds a null value.

Once GetOutcome() is called, then this property will hold either true or false.

Table 6-92 describes the possible outcomes of the Committed and UserCallCompleted properties.

Table 6-92 Outcome of OracleLogicalTransaction Committed and UserCallCompleted Properties

Committed Value UserCallCompleted Value Outcome

false

false

The call did not execute the commit.

true

true

The call did execute the commit and there was no additional information to return and no more work to do if that call was a PL/SQL procedure.

true

false

The transaction is committed, but the information returned may be incomplete and/or not all expected work was completed. Examples of incomplete information or incomplete work done include: the number of rows modified when using autocommit or commit on success, parameter and function results when calling PL/SQL procedures, or PL/SQL procedures with more work to do after the commit. In order to function correctly, .NET applications that use data returned from the commit must check the UserCallCompleted value.


ConnectionString

This property specifies a subset of the connection string used for the transaction running during the last database outage.

Declaration

// C#
public string ConnectionString {get;}

Property Value

The data source as a string.

Remarks

This connection string can be useful if the outcome is not known at the time the exception is thrown due to a service that is down. In such a scenario, use the connection string from this property along with the LogicalTransactionId to determine the outcome of the logical transaction by invoking the static OracleConnection.GetOutcome() method, once the database or service is back up.

The string returned by this property will contain only the following attributes: User Id, Proxy user Id (if not null/empty), Data Source, and Pooling (which will be set to false).

DataSource

This property specifies the data source, for example TNS alias, that is associated with the connection from which this object was obtained from.

Declaration

// C#
public string DataSource {get;}

Property Value

The data source as a string.

LogicalTransactionId

The logical transaction id is used to determine the commit outcome of the last transaction open in a database session following an outage.

Declaration

// C#
public byte LogicalTransactionId {get;}

Property Value

byte[]

Remarks

This logical transaction id can be useful if the outcome is not known at the time the exception is thrown due to a service that is down. In such a scenario, use the byte[] returned from this property (along with the ConnectionString) to determine the outcome of the logical transaction by invoking the static OracleConnection.GetOutcome() method, once the database or service is back up.

This property will return a non-null value only when the outcome is not known. For example when database or service is down, then the outcome is not known.

LogicalTransactionId property will return null if the connection has participated in a distributed transaction.

UserCallCompleted

This property specifies if the transaction completed and that the information returned may be incomplete and/or not all expected work was completed.

Declaration

// C#
public bool? UserCallCompleted {get;}

Property Value

bool

Remarks

If GetOutcome() is not called, the this property holds a null value.

Once GetOutcome() is called, then this property will hold either true or false.

Table 6-92 describes the possible outcomes of the Committed and UserCallCompleted properties.

UserId

This property specifies user ID that is associated with the connection from which this object was obtained form.

Declaration

// C#
public string UserId {get;}

Property Value

The user ID as a string.

OracleLogicalTransaction Methods

OracleLoigcalTransaction methods are listed in Table 6-93

Table 6-93 OracleLogicalTransaction Methods

Property Description

Dispose

This method releases any resources or memory allocated by the object

GetOutcome

This method retrieves the transaction outcome from the database server. The method will determine whether the transaction committed and completed or not.


Dispose

This method releases any resources or memory allocated by the object

Declaration

// C#
public void Dispose();

Implements

IDisposable

Remarks

The Dispose method also closes the OracleLogicalTransaction object.

GetOutcome

The GetOutcome method retrieves the transaction outcome from the database server. The method will determine whether the transaction committed and completed or not.

Overload List:

  • GetOutcome()

    This method uses the same connection string as the one used by the OracleConnection that instantiated/returned the OracleLogicalTransaction object.

    The connection created by this method will be closed upon return.

    Repeated calls of this method on the same instance will not incur any server round-trip.

    This property has been deprecated in 12.1.0.2. It will be desupported in a future release.

  • GetOutcome(string userid, string password, string dataSource)

    This method uses the connection information provided by the parameters to this method.

    The connection created by this method will be closed upon return.

    Repeated calls of this method on the same instance will not incur any server round-trip.

    This property has been deprecated in 12.1.0.2. It will be desupported in a future release.

  • GetOutcome(string constring, byte[] ltxid, out bool? bCommitted, out bool? bUserCallCompleted)

    The application can use this static method to determine the outcome if the outcome was not known when the exception was raised.

    The application will need to obtain the connection string and logical transaction id from the OracleException.OracleLogicalTransaction object before calling this method.

    The supplied connection string will be used to establish a connection to the database to determine the outcome of the provided logical transaction id.

    ODP.NET implicitly calls GetOutcome under the following conditions:

    • Transaction Guard is enabled on the service

    • OracleException is raised

    • The exception is a recoverable error

    When all of the above is true, then the OracleException.OracleLogicalTransaction property will be non-null.

    If a connection is involved in a distributed transaction, then GetOutcome is not called implicitly and the OracleException.OracleLogicalTransaction.LogicalTransactionId property returns null.

Note:

Once one server round-trip is incurred for the GetOutcome() invocation, the PL/SQL ForceOutcome is never invoked again against the server for a given OracleLogicalTransaction object.