3 Replies Latest reply on Jul 1, 2020 6:49 AM by John Ticehurst

    Does ORACLE BulkCopy using ODP.Net support XMLType columns ?

    John Ticehurst

      Hi,

      Does ORACLE BulkCopy using ODP.Net support XMLType columns ?

      I am trying this with the Oracle DataAccess.dll 4.122.1.0

      The following console app throws an Unsupported column datatype exception for the FREDDO table

       

      Thanks,

      John

       

      CREATE TABLE  PERF.FREDDO 

      (

      PRIMEACNO  NUMBER(9,0),

      TRANCODE  xmltype

         )

       

      using System;

      using System.Data;

      using Oracle.DataAccess.Client;

       

       

      namespace ConsoleApp6

      {

      class Program

      {

      static void Main(string[] args)

      {

       

       

      WriteToServer(CreateDataTable());

       

       

      }

      public static void WriteToServer(DataTable dataTable)

      {

      try

      {

      using (OracleConnection Oracleconnection = new OracleConnection(connstring))

      {

      Oracleconnection.Open();

      using (OracleBulkCopy bulkCopy = new OracleBulkCopy(Oracleconnection))

      {

      bulkCopy.DestinationTableName = "PERF.FREDDO";

      bulkCopy.WriteToServer(dataTable);

      }

      }

      }

      catch (Exception exc)

      {

       

      }

      }

      public static DataTable CreateDataTable()

      {

      try

      {

      DataTable table = new DataTable();

       

       

      DataColumn idDataColumn = new DataColumn("PRIMEACNO", typeof(decimal));

      idDataColumn.AllowDBNull = false;

      table.Columns.Add(idDataColumn);

      DataColumn nameDataColumn = new DataColumn("TRANCODE", typeof(string));

      nameDataColumn.AllowDBNull = false;

      table.Columns.Add(nameDataColumn);

       

       

      DataRow row = table.NewRow();

      row["PRIMEACNO"] = 1;

      row["TRANCODE"] = "<item1><item2>64</item2></item1>";

       

       

      table.Rows.Add(row);

       

       

      return table;

      }

      catch (Exception exc)

      {

      return null;

      }

      }

       

       

      }

      }