View a SYS.XMLTYPE returned from an Oracle function, using PL/SQL
- by caerphilly
I have an Oracle function that dynamically creates an XML document, and returns it in a SYS.XMLTYPE value.
I want to run a query from SQL Developer that calls that function and prints the document (either via a select, or dbms_output - I don't care).
But all the examples/documentation seem to refer to querying XML columns in tables, and I can't seem to get the syntax right for my particular usage. I'd like something like this:
declare
x SYS.XMLTYPE;
begin
x := my_package.my_function();
select x.getclobval() from x; -- doesn't work!
end;
How can I print out the value of the XML type variable 'x' in the above code?