XMLPUBLISH_STREAM Stored Procedure | XML Data Type | VantageCloud Lake - XMLPUBLISH_STREAM - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Publishes one or more XML documents as a stream.

The XMLPUBLISH_STREAM stored procedure publishes one or more XML documents as a stream. The entire document to be published is not materialized all at once. Instead, XMLPUBLISH_STREAM returns XML in chunks to be concatenated on the client side to create well-formed XML document(s). This allows construction of large documents within memory constraints.

While processing a document, XMLPUBLISH_STREAM converts certain special characters to character entity references. For example, it converts '<' to '&lt;' and '&' to' &amp;'. This conversion escapes special characters in the data to produce well-formed XML. An empty element is returned for an empty string and the element is missing for a null string.

The stored procedure takes the following as input arguments:
  • An SQL query string
  • A mapping stylesheet to transform the results of the SQL query to the desired XML structure.

    If you do not specify a mapping (you pass NULL as the Xslt argument), the procedure returns the canonical XML representation as output.

The procedure returns a result set composed of one column: XmlString. The client application concatenates the values in the XmlString column to create the XML document to be published.

If you specify documentGroupingSpec, XMLPUBLISH_STREAM allows the construction of multiple XML documents by grouping the query results based on documentGroupingSpec. The result set is interspersed with NULLs which mark the boundaries of the documents.

Recommendation: Use the XMLPUBLISH stored procedure instead of XMLPUBLISH_STREAM for these cases:
  • The size of the documents being published is small
  • The use of Teradata specific instructions, like teradata_group, is optional
  • You need to publish multiple documents
See the following sections:

For information on defining an XSLT stylesheet that represents a mapping for XML publishing, see Mapping SQL Query Results to an XML Format.

Required Privileges

The XMLPUBLISH_STREAM stored procedure is created under the user TD_SYSXML.

The user invoking this stored procedure must have the following privileges:
  • EXECUTE PROCEDURE on TD_SYSXML
  • SELECT privilege on the staging table
  • GRANT ALL (insert/update/delete/upsert) on the target tables

Result Type

The result set is composed of a single column, XmlString, whose values need to be concatenated to create the XML document to be published.