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.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.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;