dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleErrorCollection Class
Members Example

In This Topic
    OracleErrorCollection Class
    In This Topic
    Collects errors of an exception generated by dotConnect for Oracle. This class cannot be inherited.
    Syntax
    'Declaration
     
    Public Class OracleErrorCollection 
       Implements System.Collections.ICollectionSystem.Collections.IEnumerable 
    public class OracleErrorCollection : System.Collections.ICollectionSystem.Collections.IEnumerable  
    Remarks
    This class is created by OracleException to collect instances of the OracleError class. OracleErrorCollection always contains at least one instance of the OracleError class. This class is often used when a user executes DML array binding operations to obtain detailed information in case of multiple errors.
    Example
    In the following sample, we try to insert to the Dept table several rows with the same primary key. Provided that the table is empty, there should be an ORA-24381 error (errors in DML array) and three ORA-00001 errors (unique constraint violation) in OracleErrorCollection of the exception thrown.
    // Open a connection and configure a command inserting rows to the Dept table.
    OracleConnection conn = new OracleConnection("User Id=Scott;Password=tiger;Data Source=Ora1110");
    conn.Open();
    
    OracleCommand cmd = new OracleCommand("INSERT INTO dept VALUES(:deptno_p, :dname_p, :loc_p)", conn);
    
    cmd.Parameters.Add("deptno_p", OracleDbType.Integer);
    cmd.Parameters.Add("dname_p", OracleDbType.VarChar);
    cmd.Parameters.Add("loc_p", OracleDbType.VarChar);
    
    // Populate the parameter collection with arrays. 
    // Notice that the deptno_p parameter array consists of identical numbers.
    cmd.Parameters["deptno_p"].Value = new int[] { 10, 10, 10, 10 };
    cmd.Parameters["dname_p"].Value = new string[] { 
       "ACCOUNTING", "RESEARCH", "SALES", "OPERATIONS" };
    cmd.Parameters["loc_p"].Value = new string[] { 
       "NEW YORK", "DALLAS", "CHICAGO", "BOSTON" };
    
    try {
      cmd.ExecuteArray(4);
    }
    // An exception will be thrown as the unique constraint is violated.
    catch (OracleException ex) {
      OracleErrorCollection errorCollection = ex.Errors;
      foreach (Devart.Data.Oracle.OracleError error in errorCollection) {
        // Ignore the first non-informative exception ('errors in DML array')
        if (error.Code != 24381)
          Console.WriteLine(error.Message);
      }
    }
    
    Console.Read();
    ' Open a connection and configure a command inserting rows to the Dept table.
    Dim conn = New OracleConnection("User Id=Scott;Password=tiger;Data Source=Ora1110")
    conn.Open()
    
    Dim cmd = New OracleCommand("INSERT INTO dept VALUES(:deptno_p, :dname_p, :loc_p)", conn)
    
    cmd.Parameters.Add("deptno_p", OracleDbType.Integer)
    cmd.Parameters.Add("dname_p", OracleDbType.VarChar)
    cmd.Parameters.Add("loc_p", OracleDbType.VarChar)
    
    ' Populate the parameter collection with arrays. 
    ' Notice that the deptno_p parameter array consists of identical numbers.
    cmd.Parameters("deptno_p").Value = New Integer() {10, 10, 10, 10}
    cmd.Parameters("dname_p").Value = New String() {"ACCOUNTING", "RESEARCH", "SALES", "OPERATIONS"}
    cmd.Parameters("loc_p").Value = New String() {"NEW YORK", "DALLAS", "CHICAGO", "BOSTON"}
    
    Try
        cmd.ExecuteArray(4)
        ' An exception will be thrown as the unique constraint is violated.
    Catch ex As OracleException
        Dim ErrorCollection As OracleErrorCollection = ex.Errors
        For Each OraError As Devart.Data.Oracle.OracleError In ErrorCollection
            ' Ignore the first non-informative exception ('errors in DML array')
            If OraError.Code <> 24381 Then _
                Console.WriteLine(OraError.Message)
        Next
    End Try
    
    Console.Read()
    Inheritance Hierarchy

    System.Object
       Devart.Data.Oracle.OracleErrorCollection

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also