Example: Dynamic Result Row Specification - 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™

The following example defines a table function named extract_store_data that has variable output columns.

The SELECT request following the function definition uses extract_store_data to parse the input text string and extract store sales data into the store_data table.

     CREATE FUNCTION extract_store_data (
       text       VARCHAR(32000),
       from_store INTEGER)
     RETURNS TABLE VARYING COLUMNS (10)
     SPECIFIC extract_store_data
     LANGUAGE C
     NO SQL
     PARAMETER STYLE SQL
     NOT DETERMINISTIC
     EXTERNAL NAME 'SS!extract_store_data!extract_store_data.c';
     INSERT INTO store_data
     SELECT * 
     FROM (TABLE(extract_store_data('…', 1000) 
     RETURNS store_data) AS store_sales;