Reference Guide > TDV Support for SQL Functions > TDV-Supported XML Functions > XMLATTRIBUTES
 
XMLATTRIBUTES
The XMLATTRIBUTES function constructs XML attributes from the arguments provided. The result is an XML sequence with an attribute node for each input value.
Syntax
XMLATTRIBUTES ( <XML_attribute_value> [ AS <XML attribute_name> ] [ { , <XML_attribute_value> [ AS <XML attribute_name> ] }... ] )
 
In the syntax, XML_attribute_value is a value expression, and XML_attribute_name is the element identifier.
Remarks
XMLATTRIBUTES can only be used as an argument of the XMLELEMENT function.
This function requires the AS keyword if aliases are used. This is in contrast to the select-list, which does not require the AS keyword for aliasing.
This function cannot be used to insert blank spaces or newline characters.
Any <value expression> that evaluates to NULL is ignored.
Each <value expression> must have a unique attribute name.
If the result of every <value expression> is NULL, the result is NULL.
Example
SELECT XMLELEMENT (name Details, XMLATTRIBUTES (product_id,name as "Name"),
XMLELEMENT (name orderno, OrderID),
XMLELEMENT (name status, Status),
XMLELEMENT (name price, UnitPrice)) myOutput
FROM /shared/examples/ds_orders/orderdetails
WHERE ProductID < 20