Forum Stats

  • 3,875,435 Users
  • 2,266,915 Discussions
  • 7,912,212 Comments

Discussions

Bulk insert with Unicode fields

User_0J77A
User_0J77A Member Posts: 2 Green Ribbon

Hi there,

I'm using the OracleBulkCopy functionality to insert data into a table, but am running into issues with Unicode fields.

I am making use of the latest version of the Oracle.ManagedDataAccess library (v.19.11.0), targeting the full .NET Framework (4.7.1).

My test table was created using the following statement:

CREATE TABLE TestTable 
(
   StringValue1 VARCHAR2(100),
   StringValue2 NVARCHAR2(100)
)

The C# code that inserts the data looks like this:

using (var bulkCopy = new OracleBulkCopy(connection))
{
   bulkCopy.DestinationTableName = "TestTable";
   var table = new DataTable("TestTable");
   table.Columns.Add("StringValue1", typeof(string));
   table.Columns.Add("StringValue2", typeof(string));
   var row = table.NewRow();
   row["StringValue1"] = "ABC";
   row["StringValue2"] = "ABC";
   table.Rows.Add(row);
   bulkCopy.WriteToServer(table);
}

The code executes without any errors. When selecting the results from the table I see the following:


As you can see from the result, the NVARCHAR2 field was not populated correctly. Is this a bug in the library or is there some additional logic required for Unicode fields?

Any help would be be appreciated!

Claudio BonacciUser_NH1OP

Best Answer

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 3,154 Employee
    Answer ✓

    Thanks for reporting the bug. I was able to reproduce the issue with managed ODP.NET 19.11. The same test case works when using unmanaged ODP.NET 19c.

    I filed bug 32702522 to track this issue. The dev team will review and fix it.

Answers