This function converts an XML value into the corresponding representation in an alternative character-string data-type. XMLSERIALIZE converts XML types to string types for export to user host-variables.
Note: When XMLSERIALIZE is used to externalize floating point data, 15 is the maximum number of significant digits produced.
Following is the syntax diagram for XMLSERIALIZE:
├── XMLSERIALIZE ─ ( ─┬─ DOCUMENT ─┬─ xml-value-expression ─ AS ─ data-type ──► └─ CONTENT ──┘ ►─ ) ─────────────────────────────────────────────────────────────────────────┤
Specifies that the result of the xml-value-expression is a validly formed XML document.
Specifies well-formed XML content.
Any expression whose result is an XML value, such as XMLELEMENT (see XMLELEMENT), XMLCONCAT (see XMLCONCAT), or XMLFOREST (see XMLFOREST).
Must specify some character-string type.
The following example is a repetition of our XMLELEMENT example and produces a Customer element for each customer, with customer number and name attributes:
SELECT XMLSERIALIZE(CONTENT
XMLELEMENT(NAME "Customer",
XMLATTRIBUTES(CustNo,
surName as LastName,
FirstName)
)
AS VARCHAR(200)) AS "CustomerList"
FROM customers
The result of the previous example follows:
CustomerList VARCHAR(200) --------------------------------------------------------------------------------- <-Customer CustNo="000001" LastName="Sturlasson" FirstName="Snorri"><-/Customer> <-Customer CustNo="000002" LastName="Skallagrimsson" FirstName="Eigil"><-/Customer> ---------------------------------------------------------------------------------
|
Copyright © 2014 CA.
All rights reserved.
|
|