OracleErrorCollection Class
Collects errors of an exception generated by dotConnect for Oracle. This class cannot be inherited.
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()
System.Object
Devart.Data.Oracle.OracleErrorCollection
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