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!

Bulk insert into tables with non uppercase column names fails

User_8PDB1Feb 17 2021

Hi all,
I try to use the ODP.NET OracleBulkInsert method to insert data into a table.
I create the table like this:

CREATE TABLE  "DestinationSimple"
(
    "Col1" INT NOT NULL,
    "Col2" VARCHAR2(100) NULL
)

The C# code which uses the OracleBulkCopy class and a DataTable to insert the data looks like this:

using (OracleBulkCopy bulkCopy = new OracleBulkCopy(DbConnection))
{
    bulkCopy.BulkCopyTimeout = 0;
    bulkCopy.DestinationTableName = "DestinationSimple";
    DataTable dt = new DataTable("DestinationSimple");
    dt.Columns.Add("Col1");
    dt.Columns.Add("Col2");
    var r = dt.NewRow();
    r["Col1"] = 1;
    r["Col2"] = "Test";
    dt.Rows.Add(r);
    bulkCopy.WriteToServer(dt);
}

This will result in the exception message: Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-02373: Error parsing insert statement for table ETLBOX."DestinationSimple". ORA-00904: "COL2": invalid identifier
I am using Oracle.ManagedDataAccess.Core (2.19.101)
When I use upper-case columns names, the code will work without throwing an exception.
I also tried to use columnnames with quotes: dt.Columns.Add("\"Col1\"");
But without success.
To me it looks like a bug - seems to me that the OracleBulkCopy does not support case-sensisitive column names.
I would appreciate any help with this!

Comments
Post Details
Added on Feb 17 2021
8 comments
1,793 views