Purpose
The XMLFOREST function builds an XML element forest by converting each parameter into an XML element and concatenating them, returning an XMLType.
Syntax
XMLFOREST
( value_expr [ AS { c_alias | EVALNAME value_expr } ]
[, value_expr [ AS { c_alias | EVALNAME value_expr } ]
]...
)
Parameters
| Field | Description |
|---|---|
| value_expr | The name of the column containing the data value to be marked. |
| AS tag | Specifies the tag name. If the expression is a column name, the AS clause is optional. The default tag name is the column name (in uppercase letters). If the expression is not a column name (for example, an aggregate function, a literal, or the concatenation of two columns), the AS clause is required. |
| tag | The name of the XML tag, which must conform to XML naming standards. It can be specified as a string. EVALNAME is followed by an expression that evaluates to a string literal. |
Return type
The concatenated XMLType after the XMLTYPE is concatenated.
Examples
obclient> create table xml_test( n1 NUMBER, n2 NUMBER, c1 VARCHAR2(10), c2 VARCHAR2(10));
obclient> insert into xml_test values(1, 11, 'a', 'bb');
obclient> insert into xml_test values(2, 22, 'c', 'dd');
# Place the value of n1 in the tag1 element and the value of n2 in the tag2 element, and return the concatenated XMLType.
obclient> select xmlforest(n1 as tag2, n2 as tag2) from xml_test;
<TAG1>1</TAG1><TAG2>11</TAG2>
<TAG1>2</TAG1><TAG2>22</TAG2>