OracleError Class

The OracleError class represents an error reported by Oracle.

Class Inheritance

System.Object

  Oracle.DataAccess.Client.OracleError

Declaration

// C#
public sealed class OracleError

Thread Safety

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

Remarks

The OracleError class represents a warning or an error reported by Oracle.

If there are multiple errors, ODP.NET only returns the first error message on the stack.

Example

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client;
 
class OracleErrorsSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    // Create an OracleCommand object using the connection object
    OracleCommand cmd = con.CreateCommand();
 
    try
    {
      cmd.CommandText = "insert into notable values (99, 'MyText')";
      cmd.ExecuteNonQuery();
    }
    catch (OracleException ex)
    {
      Console.WriteLine("Record is not inserted into the database table.");
 
      foreach (OracleError error in ex.Errors) 
      {
        Console.WriteLine("Error Message: " + error.Message);
        Console.WriteLine("Error Source: " + error.Source);       
      }
    }
  }
}

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccess.dll

ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4


OracleError Members

OracleError members are listed in the following tables.

OracleError Static Methods

The OracleError static method is listed in Table 5-50.

Table 5-50 OracleError Static Method

Method Description

Equals

Inherited from System.Object (Overloaded)


OracleError Properties

OracleError properties are listed in Table 5-51.

Table 5-51 OracleError Properties

Property Description

ArrayBindIndex

Specifies the row number of errors that occurred during the Array Bind execution

DataSource

Specifies the Oracle service name (TNS name) that identifies the Oracle database

Message

Specifies the message describing the error

Number

Specifies the Oracle error number

Procedure

Specifies the stored procedure that causes the error

Source

Specifies the name of the data provider that generates the error


OracleError Methods

OracleError methods are listed in Table 5-52.

Table 5-52 OracleError Methods

Method Description

Equals

Inherited from System.Object (Overloaded)

GetHashCode

Inherited from System.Object

GetType

Inherited from System.Object

ToString

Returns a string representation of the OracleError



OracleError Static Methods

The OracleError static method is listed in Table 5-53.

Table 5-53 OracleError Static Method

Method Description

Equals

Inherited from System.Object (Overloaded)



OracleError Properties

OracleError properties are listed in Table 5-54.

Table 5-54 OracleError Properties

Property Description

ArrayBindIndex

Specifies the row number of errors that occurred during the Array Bind execution

DataSource

Specifies the Oracle service name (TNS name) that identifies the Oracle database

Message

Specifies the message describing the error

Number

Specifies the Oracle error number

Procedure

Specifies the stored procedure that causes the error

Source

Specifies the name of the data provider that generates the error


ArrayBindIndex

This property specifies the row number of errors that occurred during the Array Bind execution.

Declaration

// C#
public int ArrayBindIndex {get;}

Property Value

An int value that specifies the row number for errors that occurred during the Array Bind execution.

Remarks

Default = 0.

This property is used for Array Bind operations only.

ArrayBindIndex represents the zero-based row number at which the error occurred during an Array Bind operation. For example, if an array bind execution causes two errors on the 2nd and 4th operations, two OracleError objects appear in the OracleErrorCollection with the ArrayBindIndex property values 2 and 4 respectively.

DataSource

This property specifies the Oracle service name (TNS name) that identifies the Oracle database.

Declaration

// C#
public string DataSource {get;}

Property Value

A string.

Message

This property specifies the message describing the error.

Declaration

// C#
public string Message {get;}

Property Value

A string.

Number

This property specifies the Oracle error number.

Declaration

// C#
public int Number {get;}

Property Value

An int.

Procedure

This property specifies the stored procedure that causes the error.

Declaration

// C#
public string Procedure {get;}

Property Value

The stored procedure name.

Remarks

Represents the stored procedure which creates this OracleError object.

Source

This property specifies the name of the data provider that generates the error.

Declaration

// C#
public string Source {get;}

Property Value

A string.


OracleError Methods

OracleError methods are listed in Table 5-55.

Table 5-55 OracleError Methods

Method Description

Equals

Inherited from System.Object (Overloaded)

GetHashCode

Inherited from System.Object

GetType

Inherited from System.Object

ToString

Returns a string representation of the OracleError


ToString

Overrides Object

This method returns a string representation of the OracleError.

Declaration

// C#
public override string ToString();

Return Value

Returns a string with the format Ora- error number: Class.Method name error message stack trace information.

Example

ORA-24333: zero iteration count