CREATE/REPLACE FUNCTION Examples | Teradata Vantage - Example: Creating a Function from Input Arguments - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
ncd1596241368722.ditamap
dita:ditavalPath
hoy1596145193032.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

This example takes variable input arguments based on input from a previous correlated subquery in the FROM clause of a SELECT request, that is not shown. The function definition inputs XML text, which it then parses to extract a customer ID, store number, and the set of items purchased. The output produces one row per item purchased, with the columns being based on existing columns in the table defined in the function definition.

    CREATE FUNCTION xml_extract( xml_text VARCHAR(64000))
      RETURNS TABLE (cust_id INTEGER,
                     store   INTEGER,
                     item    INTEGER)
    LANGUAGE C
    NO SQL
    EXTERNAL;