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

XMLForest [Oracle SQL]

XMLForest (value-expr)
XMLForest (value-expr as alias-name)
XMLForest (value-expr as alias-name, value-expr as alias-name [,...])

An example

create table xml_forest_test (
  some_id    number   primary key,
  some_col_1 varchar2(10),
  some_col_2 date,
  some_col_3 number(5)
);
alter session set nls_date_format='dd-mon-yyyy';

insert into xml_forest_test values( 1, 'one'  , '15-jan-1974', 74);
insert into xml_forest_test values( 2, 'two'  , '28-mar-1891', 18);
insert into xml_forest_test values( 3, 'three', ' 7-sep-1599', 59);
insert into xml_forest_test values( 4, 'four' , '10-aug-1616', 16);
insert into xml_forest_test values( 5, 'five' , '19-oct-1904', 19);
select XMLForest (some_col_1 as "col-1", some_col_2 as "col-2", some_col_3 as "col-3") "Forest" 
from xml_forest_test
where some_id = 4;
Forest
--------------------------------
<col-1>four</col-1>
<col-2>10-aug-1616</col-2>
<col-3>16</col-3>