René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

sys_xmlagg [Oracle SQL]

sys_xmlagg (expression)
sys_xmlagg (expression, 'format-string')

An example

select
  sys_xmlagg(
    value(tab),   -- expression
    xmlformat('Foo')
  )
from
  table (
    xmlsequence(
      extract( 
        XMLType(
        '<things>
           <item><name>spoon</name><price>  4.89</price></item>
           <item><name>table</name><price>899.00</price></item>
           <item><name>chair</name><price>279.00</price></item>
         </things>
        '
        ),'/things/item'
      )
    )
  ) tab
where
  extractvalue(value(tab),'/item/price') < 500;
SYS_XMLAGG(VALUE(TAB),--EXPRESSIONXMLFORMAT('FOO'))
---------------------------------------------------------------
<?xml version="1.0"?>
<Foo>
<item>
  <name>spoon</name>
  <price>  4.89</price>
</item>
<item>
  <name>chair</name>
  <price>279.00</price>
</item>
</Foo>