issues with bulk insert into Oracle using ODP.NET and C#
506723May 8 2006 — edited May 8 2006Hi
I am using ODP.net Array Binding feature to insert the data ,I am able to insert the data sucessfully but the data were inserted in diffrent order.
suppose if i have the array initialized as below
data[0] = 1;
data[1] = 2;
data[2] = 3;
data[3] = 4;
.
.
.
.
data[9999] =9999
data get inserted ino the tabke as below
9999
8000
8001
7999
2000
2002
2003
.
.
.
.
below is the code i have
//initializing array
int[] data = new int[10000];
for (int iCol = 0; iCol < 10000; iCol++)
{
data[iCol] = iCol;
}
//create the command
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand("Insert into TestData values(:ID)", connection);
command.ArrayBindCount = 10000;
//add the parameter
OracleParameter deptNoParam = new OracleParameter(ID, OracleDbType.Int32);
deptNoParam.Direction = ParameterDirection.Input;
deptNoParam.Value = data;
command.Parameters.Add(deptNoParam);
try
{
connection.Open();
command.ExecuteNonQuery();
Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
}
catch (Exception e)
{
Console.WriteLine("Execution Failed:" + e.Message);
}
finally
{
// connection, command used server side resource, dispose them
// asap to conserve resource
}
It will be great if some one give the reason why data geting inserted in diffrent order and solution for the same or any other alternate approach for bulk insertion.
Thanks,
Raj