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 '<' and '&' to' &'. 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.
- 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.
- 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
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.
- 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.