RE: XML Question

  • From: "Davey, Alan" <ddavey@xxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 20 Sep 2005 10:42:56 -0400

Thanks for the replies Brian and Ian.
 
Brian, that certainly does the trick, but leaves me feeling dirty, as my
pl/sql routines are going to be called fairly often.
 
The XML document that I am producing will be fairly large, so various
pl/sql routines are building different parts that then get concatenated
together in the end.  My hope was to use constant variables for the
element name in case there was a minor change in the xml schema down the
road.  I suppose the argument could be made to just use literals and
update them when the schema changes, since the receiver of the xml
document should be able to use the latest schema as well.
 
Since some of my xml data is strictly header information, I was hoping
to avoid hitting dual at all and doing something like:
  l_xml := xmlelement(...);
 
But it seems that the xmlelement function only works as part of a select
statement.
 
Regards,
 
Alan Davey

________________________________

From: Ian Cary (C) [mailto:Ian.Cary@xxxxxxxxxxxxxxxxxxxx] 
Sent: Tuesday, September 20, 2005 10:30 AM
To: Davey, Alan; oracle-l@xxxxxxxxxxxxx
Subject: RE: XML Question


Would this help?
 

  1  declare
  2   cName constant varchar2(4) := 'Name';
  3   l_xml xmltype;
  4   begin
  5     execute immediate 'select xmlelement('||cname||',''Larry'') from
dual'
  6     into l_xml;
  7     dbms_output.put_line(l_xml.getCLOBVal());
  8*  end;
MP401SH2> /
<NAME>Larry</NAME>
 
PL/SQL procedure successfully completed.
 
Cheers,
 
Ian

         

Other related posts: