17.10 - Example: XSLT_SHRED Usage Example - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - XML Data Type

Advanced SQL Engine
Teradata Database
Release Number
July 2021
Last Update
Content Type
Programming Reference
Publication ID
English (United States)

This example shows how to use XSLT_SHRED.

Before running the example, ensure the test user is created with the required permissions and the required tables are created. See Setting Up the XSLT_SHRED_BATCH and XSLT_SHRED Examples for details.

Call the XSLT_SHRED stored procedure to shred the XML document. The following arguments are used for the call.

  • The xmlDoc is created automatically in this example with the NEW XML statement.
  • The xsltMapping argument is supplied by invoking the CREATEXML function with a stylesheet as input. This stylesheet will be applied to the XML document.
  • The externalContext is NULL.
  • The resultCode is returned in :res. A successful operation returns 0.
	CREATEXML('<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
extension-element-prefixes="date" version="1.0" >
<xsl:param name="XML_TimeStamp" select="date:date-time()"/>
<xsl:template match="/Root">
     <xsl:for-each select="AllTypes">
       <C_Datec genexp="(? as Date)"><xsl:value-of select="DateTime/Datec"/></C_Datec>
       <C_Timec genexp="(? as Time(6))">
          <xsl:value-of select="DateTime/Timec"/></C_Timec>
       <C_Timewzc genexp="(? as Time(6) WITH TIME ZONE)">
          <xsl:value-of select="DateTime/Timewzc"/></C_Timewzc>
       <C_TimeStampc genexp="(? as TIMESTAMP(6))">
          <xsl:value-of select="DateTime/TimeStampc"/></C_TimeStampc>
       <C_TimeStampwzc genexp="(? as TIMESTAMP(6) WITH TIME ZONE)" default="{$XML_TimeStamp}">
          <xsl:value-of select="DateTime/TimeStampwzc"/></C_TimeStampwzc>
</xsl:stylesheet>'), '',:res);
Result: To view the updated data in the target table, run: SELECT * FROM DefaultValue4;
C_Datec C_Timec C_Timewzc C_TimeStampc


00/09/10 12:12:12.000000 12:12:12.000000+00:00 2000-09-09 12:12:12.000000

2014-05-07 05:08:17.000000-04:00

00/09/09 12:12:12.000000 12:12:12.000000+00:00 2000-09-09 12:12:12.000000 2000-09-09 12:12:12.000000+00:00