17.10 - Example: Dynamic Result Row Specification - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1144-171K
Language
English (United States)

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;