Description of XMLForest.gif follows
Description of the illustration XMLForest.gif


XMLForest converts each of its argument parameters to XML, and then returns an XML fragment that is the concatenation of these converted arguments.

  • If value_expr is a scalar expression, then you can omit the AS clause, and Oracle Database uses the column name as the element name.

  • If value_expr is an object type or collection, then the AS clause is mandatory, and Oracle uses the specified c_alias as the enclosing tag. The c_alias can be up to 4000 characters.

  • If value_expr is null, then no element is created for that value_expr.


The following example creates an Emp element for a subset of employees, with nested employee_id, last_name, and salary elements as the contents of Emp:

   XMLFOREST(e.employee_id, e.last_name, e.salary))
   "Emp Element"
   FROM employees e WHERE employee_id = 204;

Emp Element

Please refer to the example for XMLCOLATTVAL to compare the output of these two functions.