The XMLSERIALIZE function returns a serialized XML value of the specified data type generated from the XML-expression argument.
.-CONTENT-. >>-XMLSERIALIZE--(--+---------+---------------------------------> >--XML-expression--AS--| data-type |----------------------------> .--------------------------------------. V .-VERSION--'1.0'---------------. (1) | >----+------------------------------+-----+--)----------------->< | .-EXCLUDING XMLDECLARATION-. | '-+-INCLUDING XMLDECLARATION-+-' data-type .-(1)----------------------------. |--+-+-CHARACTER-+--+--------------------------------+--------------------------+--| | '-CHAR------' '-(--integer--+-------------+--)-' | | +-OCTETS------+ | | '-CODEUNITS32-' | +-+-VARCHAR----------------+--(--integer--+-------------+--)-----------------+ | '-+-CHARACTER-+--VARYING-' +-OCTETS------+ | | '-CHAR------' '-CODEUNITS32-' | | .-(1M)----------------------------------. | +-+-CLOB------------------------+--+---------------------------------------+-+ | '-+-CHARACTER-+--LARGE OBJECT-' '-(--integer--+---+--+-------------+--)-' | | '-CHAR------' +-K-+ +-OCTETS------+ | | +-M-+ '-CODEUNITS32-' | | '-G-' | | .-(1M)-----------------. | '-+-BLOB-----------------+--+----------------------+-------------------------' '-BINARY--LARGE OBJECT-' '-(--integer--+---+--)-' +-K-+ +-M-+ '-G-'
The schema is SYSIBM. The function name cannot be specified as a qualified name.
If either the xml-document argument or the xsl-stylesheet argument is null, the result will be null.
Code page conversion might occur when storing any of the previously mentioned documents in a CHAR, VARCHAR, or CLOB column, which might result in a character loss.
The result has the data type specified by the user. An XML sequence is effectively converted to have a single document node by applying XMLDOCUMENT to XML-expression before serializing the resulting XML nodes. If the result of XML-expression can be null, the result can be null; if the result of XML-expression is null, the result is the null value.
Therefore, applications should avoid direct use of XMLSERIALIZE INCLUDING XMLDECLARATION that return character string types and should retrieve XML values directly into host variables to maintain the match between the external code page and the encoding in the XML declaration. If XMLSERIALIZE must be used in this situation, a BLOB type should be specified to avoid code page conversion.