Transform DT_TEXT in SSIS 2012 for Oracle CLOB

会有一股神秘感。 提交于 2019-12-24 00:26:32

问题


I am using SSIS 2012. I have a script component with an output column of type DT_TEXT. (It is XML from a web page.)

I have an OLE DB Destination using the Native OLD DB\Oracle Provider for OLE DB, and the table for that field is defined as a CLOB.

This question seems similar: SSIS Script Component won't allow text Stream Output. And this seems to give an answer: http://www.rad.pasfu.com/index.php?/archives/35-How-to-Fill-NTEXT-Column-from-Script-Component-SSIS.html

Within the Script Component I am getting my XML as a String, which the docs say can hold up to 2GB. I am having difficulty assigning it to my Output0Buffer (DT_TEXT). Any attempt to use AddBlobData gives an error.

  // Output0Buffer.AddRow();
  // Output0Buffer.forecastXML = forecastXML;
  // Output0Buffer.AddBlobData(forecastXML);
  // Output0Buffer.LargeCol.AddBlobData(forecastXML);
  // Output0Buffer.LargeCol.AddBlobData(System.Text.Encoding.UTF8.GetBytes(forecastXML));

Those are some of my attempts, but none of them compile. That last one gives the error: 'Output0Buffer' does not contain a definition for 'LargeCol' and no extension method 'LargeCol' accepting a first argument of type 'Output0Buffer' could be found (are you missing a using directive or an assembly reference?)

How do I get the text stream from the script component to the oracle destination?


回答1:


It turns out that SSIS Script Component won't allow text Stream Output did have the answer, but I had to figure out what the fields meant in the answer.

I'll explain all of the parts, so it's clear what is going on.

The Script Component has an Output called Output 0, with Output Columns forecastXML. Those are default names except for the last. forecastXML has the data type of Text stream [DT_TEXT]

In the script itself, I have a string called forecastXML (yeah, same name, which makes it confusing.)

After filling the string forecastXML with data, I can assign it to the Output0Buffer with the following lines:

String forecastXML = oResult.XmlResult;
Output0Buffer.AddRow();
Output0Buffer.forecastXML.AddBlobData(System.Text.Encoding.UTF8.GetBytes(forecastXML));

The first line works for all data types. Because I'm writing to a NTEXT, the second line is needed, rather than a straight assignment. The Output0Buffer.forecastXML refers to the NText data type defined in my Output 0. The last one is my string from the code.

To be more clear, rather than creating a string, I should have

Output0Buffer.forecastXML.AddBlobData(System.Text.Encoding.UTF8.GetBytes(oResult.XmlResult));

where oResut.XmlResult is the result of my call that gets the XML. Assigning it to a string is an extra, unneeded step.

This is going to an Oracle CLOB, so the next step is a to take that output to a Derived Column and cast my output forecastXML as (DT_NTEXT)forecastXML. (I suspect I'm doing some unneeded changes of types.)

And then, I map that field to my CLOB field in my OLE DB Destination.



来源:https://stackoverflow.com/questions/57381226/transform-dt-text-in-ssis-2012-for-oracle-clob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!