Hi,

I have created the following function, which returns a small XML instance created out of a relational table:
create or replace function sp_GetCriticalityXML return XMLType
as
critInstance XMLType;
begin
SELECT XMLELEMENT ( "Criticality", XMLAGG ( XMLELEMENT("option", XMLATTRIBUTES (criticality_id),criticality_name) ) ) AS "result"
INTO critInstance
FROM criticality;
return critInstance;
end;
/

That works just fine. But now I'd like to test it. And being an Oracle newbie, I can only go with the example I've found. So I tried running this:
VARIABLE theXML XMLType
EXECUTE :theXML := sp_getCriticalityXML();
PRINT theXML;

Which throws this error:
Usage: VAR[IABLE] [ [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]
BEGIN :theXML := sp_getCriticalityXML(); END;

*
ERROR at line 1:
ORA-06550: line 1, column 18:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored



THEXML
--------------------------------------------------------------------------------
SP2-0642: SQL*Plus internal error state 2131, context 0:0:0
Unsafe to proceed
SP2-0625: Error printing variable "thexml"

So it looks like I can't declare a variable of XMLType, even though the docs say I can. Any opinion how to work around this, and how to see what my function is actually returning?

Thanks,
Carolyn