Error with bulk insert through dotConnect for oracle

Error with bulk insert through dotConnect for oracle

Postby tej » Wed 09 Feb 2011 00:14

Hi,

I am new to using "dotConnect for Oracle."and getting an error while trying to do bulk insert into Oracle using "dotConnect for Oracle".

Following is the code I am using.

[// Open connection
conn.Open();
// Create command object with previously opened connection
OracleCommand cmd = conn.CreateCommand();
int batchSize = 1000;

StringBuilder strCommand = new StringBuilder();
strCommand.AppendFormat("INSERT INTO {0} VALUES(", fileHeader.TableName);
string paramName = String.Empty;
OracleDbType oracleDbType = OracleDbType.VarChar;
OracleParameter oracleParameter = null;
foreach (var fd in fileHeader.FileDetailsList.OrderBy(a => a.FileColumnID))
{
if (!string.IsNullOrEmpty(fd.TableColumnName))
{
if (!string.IsNullOrEmpty(fd.DataType))
{
oracleDbType = GetOracleDataType(fd.DataType);
}
else if (fd.TableColumnName == "PROCESS_DATE")
{
oracleDbType = OracleDbType.Date;
}
else
{
continue;
}
paramName = string.Format("p_{0}", fd.TableColumnName);
strCommand.AppendFormat(":{0},", paramName);
oracleParameter = new OracleParameter(paramName, oracleDbType);
cmd.Parameters.Add(oracleParameter);
dictParams.Add(fd.FileColumnID, oracleParameter);
}
}
strCommand.Remove(strCommand.Length - 1, 1);
strCommand.AppendFormat(")");
cmd.CommandText = strCommand.ToString();

BatchFileConverter bfc = new BatchFileConverter(fileToBeSaved, batchSize, fileHeader);
Dictionary> dictBatchValues = null;
while ((dictBatchValues = bfc.GetNextBatch()) != null)
{
foreach (var key in dictBatchValues.Keys)
{
if (dictParams.ContainsKey(key))
{
dictParams[key].Value = dictBatchValues[key].ToArray();
}
}
cmd.ExecuteArray(batchSize);
}

// Dispose command
cmd.Dispose();

// Close connection
conn.Close();
]

Given below is the error I am getting.

{System.ArgumentException: Argument 'Iters' must be equal to ArrayLength.
at Devart.Data.Oracle.OracleParameter.a(Object A_0, aq& A_1, OracleDbType A_2, Int32 A_3, ParameterDirection A_4, Int32 A_5, Int32 A_6, av A_7)
at Devart.Data.Oracle.OracleCommand.a(z A_0, Int32 A_1, OracleParameterCollection A_2, av A_3, Boolean& A_4)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()
at Devart.Data.Oracle.OracleCommand.ExecuteArray(Int32 iters).

Can any one help me in figuring out the issue my code?

I am using "Devart.Data.Oracle.dll" version 5.60.124.0.
[/code]
tej
 
Posts: 1
Joined: Tue 08 Feb 2011 23:34

Postby Shalex » Fri 11 Feb 2011 13:50

Please send us a small complete test project with the corresponding DDL/DML script to reproduce the issue in our environment. Also specify the versions of your Oracle Server and Oracle Client.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle