XMLPUBLISH_STREAM Stored Procedure | XML Data Type | Teradata Vantage - XMLPUBLISH_STREAM - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
kxe1590704060061.ditamap
dita:ditavalPath
kxe1590704060061.ditaval
dita:id
B035-1140
lifecycle
previous
Product Category
Teradata Vantageā„¢

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 that will 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, < is converted to &lt; and & is converted to &amp;. This is done to escape special characters in the data to ensure that well-formed XML is produced. An empty element is returned for an empty string and the element will be missing for a null string.

The stored procedure takes the following as input arguments:
  • An SQL query string
  • A mapping stylesheet that will 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 not required
  • You need to publish multiple documents

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.