Oracle XML Operations

Source: Internet
Author: User
Tags rtrim

--XmlElement multiple label levelsSELECTXMLELEMENT ("TEST", XMLELEMENT ("AA", XMLELEMENT ("BB" ,'XXX'), XMLELEMENT ("CC",'XXX')))   fromDUAL; SELECTXMLELEMENT ("test") fromDUAL----xmlattributes Multiple PropertiesSELECTXMLELEMENT ("TEST",'123', XMLELEMENT ("AA", XmlAttributes ('1235678'" Test_attribute"), XMLELEMENT ("BB", XmlAttributes ( 'Z'"Attr",NULL"XO"),'XXX'), XMLELEMENT ("CC",'XXX')),                  'qwe')   fromDUAL; --Xmlforest, if you want to define a label node property value, you cannot use theSELECTXMLELEMENT ("TEST", Xmlforest (NULL"WW",'1'"XX",'3'"XX")) fromdual;--about whether a null value produces a label that should be born--1, XmlElement null or NULL will have the end of the label does not appear </>, xmlattributes null value or null corresponding key name does not appear    SELECTXMLELEMENT ("Test", XMLELEMENT ("Test1", XmlAttributes (1"Test1_attribute"),NULL), XMLELEMENT ("Test2", XmlAttributes ("'"Test2_attribute"),"'), XMLELEMENT ("Test3", XmlAttributes (NULL"Test3_attribute")),'haha')     fromdual;--2.xmlforest NULL The entire label name does not appear, and single quotes appearSELECTXMLELEMENT ("Test", Xmlforest (NULL"Test1","'TEST3)) fromdual;--Xmlagg generating XML fragments withT as(SELECT '1'A'A'B fromDual--UNION All Select ' 2 ', ' A ' B from dual UNION all select ' 3 ', ' B ' b from dual--1SELECTXMLELEMENT ("KK", Xmlagg (XMLELEMENT ("TEST", a))) fromTGROUP  byb;--2SELECTXMLELEMENT ("TT", (SELECTXmlagg (XMLELEMENT ("TEST", a)ORDER  byA fromT)) fromdual;--SortSELECTXMLELEMENT ("KK", Xmlagg (XMLELEMENT ("TEST", a)ORDER  byADESC)) fromTGROUP  byb;--can generate invalid Xml,xml can only have one root nodeSELECTXmlagg (XMLELEMENT ("TEST", a)) fromT--The following will be an errorSELECTXMLTYPE. Createxml ('<dummy>X</dummy><dummy>y</dummy>') fromdual;--aggregation, alternative to Sys_path_connect_by,listagg withQ as (SELECT 1 KEY,'A'X fromDUALUNION  All  SELECT 2 KEY,'B'X fromDUALUNION  All  SELECT 3 KEY,'A'X fromDUALUNION  All  SELECT 4 KEY,'A'X fromDUAL)--1SELECTX,RTRIM(Xmlagg (XMLELEMENT (E,Key||',')ORDER  by Key))  asConcatval fromQGROUP  byX;--2SELECTX,RTRIM(Xmlagg (XMLELEMENT (E,KEY || ',')ORDER  by KEY)             . EXTRACT ('//text ()'),             ',') asConcatval fromQGROUP  byX

Oracle XML Operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.