Example: Dynamic Result Row Specification - Analytics Database - Teradata Vantage

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
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;