Hi all,
I try to generate some XML in PL/SQL.
select xmlelement("Date", sysdate).getClobVal() from dual;
XMLELEMENT("DATE",SYSDATE).GETCLOBVAL()
-------------------------------------------
<Date>2012-07-13</Date>
This is the date format I expected(standard XML date format).
And the Oracle Documentation describes it:
"The XML Schema standard specifies that dates and timestamps in XML data be in standard formats. XML generation functions in Oracle XML DB produce XML dates and timestamps according to this standard."
When I want to create some XML from a query, I tried this
DECLARE
l_refcursor SYS_REFCURSOR;
l_xmltype xmltype;
l_ctx dbms_xmlgen.ctxHandle;
BEGIN
OPEN l_refcursor FOR select sysdate "Date" from dual;
l_ctx := dbms_xmlgen.newContext (l_refcursor);
dbms_xmlgen.setRowTag (l_ctx, null);
dbms_xmlgen.setRowSetTag (l_ctx, null);
l_xmltype := dbms_xmlgen.getXMLType (l_ctx);
dbms_xmlgen.closeContext (l_ctx);
dbms_output.put_line(l_xmltype.getClobVal());
END;
/
<Date>13-JUL-12</Date>
I expected also the XML standard date format, but I get the nls_date_format.
Of course I can use to_char and specify the correct date format or do an alter session(alter session set nls_date_format='RRRR-MM-DD'; ), but I wonder why XMLElement uses the standard and dbms_xmlgen not.
Or is there another way to use the default XML standard?
Gert