Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How To Store XML Fragments Using Functions Such As XMLElement

littlecatOct 9 2013 — edited Oct 10 2013

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

This post has been answered by odie_63 on Oct 10 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2013
Added on Oct 9 2013
5 comments
3,646 views