xmlagg and xmlforest : Introduction « XML « Oracle PL/SQL Tutorial






SQL> CREATE TABLE products(
  2    product_id              NUMBER(6),
  3    name            VARCHAR2(50),
  4    category        VARCHAR2(50),
  5    price      NUMBER(8,2),
  6    min_price       NUMBER(8,2)
  7  );

Table created.

SQL> select xmlelement( "Prodcategory",
  2            xmlattributes(p.category as "Category"),
  3            xmlagg(xmlelement("Product",
  4            xmlforest(p.name as "Name"))))
  5  from products p
  6  group by p.category;

no rows selected

SQL>
SQL> drop table products;

Table dropped.








33.1.Introduction
33.1.1.SQL to XML
33.1.2.Create a table to hold the simple "Hello World" XML document
33.1.3.Create table based on single data type
33.1.4.Create table myTable of xmltype
33.1.5.Use Aggregrate functions on XML data
33.1.6.Use Text() function to get text value from xml string
33.1.7.xmlagg and xmlforest
33.1.8.Without the text() operator, returns node name + text value