ORA-26026 / ORA-01452 in OracleLoader
Posted: Tue 26 Feb 2013 07:06
Due to the fact that array binding is not working at the moment (see http://forums.devart.com/viewtopic.php?f=1&t=25822) I try to use the Oracle Loader functionality. According to the documentation it is only supported in OCI Mode. If I try inserting data in OCI mode I will get a ORA-26026 which should not occur. The documentation says that the primary key constraint is enabled.
Here is my example code (Please execute it twice).
Calling loader.Close() in the 2nd run will cause an ORA-26026 exception internally which I cannot catch. If I look at the table I see duplicated entries and that's why when rebuiling the indexes I will get an ORA-01452 exception. The only solution is to drop the primary key, remove the duplicates and then to add the primary key again. But this is not feasible if tables are getting bigger.
I also tried this in direct mode although I know it is not officially supported. But the behaviour is the same.
Here is my example code (Please execute it twice).
Code: Select all
OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder
{
Direct = false,
Server = "test",
ServiceName = "test",
Sid = "test",
Port = 1521,
UserId = "TEST",
Password = "TEST"
};
String ConnString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + oraCSB.Server
+ ")(PORT= 1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + oraCSB.Sid + ")));User Id="
+ oraCSB.UserId + ";Password=" + oraCSB.Password + ";";
OracleConnection connection = new OracleConnection(ConnString);
connection.Open();
connection.AutoCommit = true;
OracleCommand Command = connection.CreateCommand();
Command.CommandText = "create table test (column1 varchar2(24) NOT NULL,column2 INTEGER, Column3 REAL, CONSTRAINT PK_TEST PRIMARY KEY (Column1))";
try
{
Command.ExecuteNonQuery();
}
catch (Devart.Data.Oracle.OracleException ex)
{
string exception = ex.Message;
}
Command.Dispose();
OracleLoader loader = new OracleLoader();
loader.Connection = connection;
loader.TableName = "test";
loader.CreateColumns();
for (int i = 0; i < 2; i++)
{
loader.Open();
try
{
loader.SetValue(0, "test1");
loader.SetValue(1, 0);
loader.SetValue(2, 0.0);
loader.NextRow();
loader.SetValue(0, "test2");
loader.SetValue(1, 0);
loader.SetValue(2, 0.0);
loader.NextRow();
loader.SetValue(0, "test3");
loader.SetValue(1, 0);
loader.SetValue(2, 0.0);
loader.NextRow();
loader.Close();
}
catch (Devart.Data.Oracle.OracleException ex)
{
string test = ex.Message;
}
}
I also tried this in direct mode although I know it is not officially supported. But the behaviour is the same.