Skip to content
Advertisement

Returning multiple XML from ref cursor oracle

There is a procedure in the Oracle DB which takes a date range and generates XML file for each day and the return type is ref cursor.

When the procedure is called from C# code, I am unable to extract the XML from the cursor. Any pointers will be helpful on how to extract the XML

Below given is the small example of the query which is returning the XML’s as ref cursor from the procedure call.

As per the query it returns multiple XML for each date that is returned as ref cursor. Just wanted some pointers on how to extract the multiple xml’s from the ref cursor that will be output parameter from the C# code.

Advertisement

Answer

Your code has a few issues (including calling TO_DATE on values that are already dates) and can be much simpler; however, the main change is to call .getStringVal() on the created element as this will convert it from an XMLTYPE data type to a VARCHAR2 string and then you can just get the XML as you would any other string from each row of the returned cursor:

If the data you generate is too large for a VARCHAR2 then use .getClobVal() instead.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement