Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

issues with bulk insert into Oracle using ODP.NET and C#

506723May 8 2006 — edited May 8 2006
Hi

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2006
Added on May 8 2006
1 comment
749 views