XML Question

  • From: "Davey, Alan" <ddavey@xxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 20 Sep 2005 09:59:17 -0400

Hi,

I have a pl/sql routine that is generating XML data.  When calling
function xmlelement(), I want to supply a variable as the first
parameter.  However, Oracle (v10.1.0.4 on windows) takes the parameter
name (not its value) and uses it as the element name as the following
example shows:

Wrote file afiedt.buf

  1  declare
  2  cName constant varchar2(4) := 'Name';
  3  l_xml xmltype;
  4  begin
  5    select xmlelement(cName,'Larry')
  6    into l_xml
  7    from dual;
  8    dbms_output.put_line(l_xml.getCLOBVal());
  9* end;
adavey@EASDEV> /
<CNAME>Larry</CNAME>

PL/SQL procedure successfully completed.

If you replace cName with xyz (no quotes), Oracle runs the pl/sql and
uses <xyz> as the element tag name.  Every example that I see in the FM
is using a literal string for the element name.  Is it possible to use a
variable name for this parameter?  If not, is this just an oversight on
the part of Oracle?  

Thanks,
-------------------------------
Alan Davey
Senior Programmer/Analyst, Advertising Solutions
Oracle 9i OCA; 3/4 OCP
Harris Corporation
w) 212-295-3458


Other related posts: