Hi
Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
declare
vTheData XMLType;
vTheDataClob clob;
begin
vTheData:= XMLelement("empno",'1234567');
vTheDataClob:= xmlelement("empno",'1234567').getclobval();
end;
Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
declare
vTheData XMLType;
vTheDataClob clob;
begin
select xmlelement("empno",'1234567')
into vTheData
from dual;
select xmlelement("empno",'1234567').getclobval()
into vTheDataClob
from dual;
end;
Hope this makes sense.
Thanks