16.20 - Example Query - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
English (United States)

Here is an example of how to invoke the table function with constant expression input arguments and get a result row with four columns:

SELECT *
FROM TABLE (get_data('1356,122,20061009,abc')
RETURNS (col1 INTEGER, col2 BYTEINT, col3 DATE, col4 VARCHAR(5)))
AS t1;

Here is another example of how to invoke the table function with constant expression input arguments and get a result row with three columns:

SELECT *
FROM TABLE (get_data('1234,56,20061010')
RETURNS (col1 INTEGER, col2 BYTEINT, col3 DATE))
AS t1;

Here is an example of how to invoke the table function using the columns from a derived table as input arguments:

SELECT tf.col1, tf.col2, tf.col3, tf.col4
FROM raw_cust,
     TABLE (get_data(raw_cust.text)
RETURNS (col1 INTEGER, col2 BYTEINT, col3 DATE, col4 VARCHAR(5)))
AS tf;

Here is the definition of the raw_cust table:

CREATE TABLE raw_cust (C1 INT, text VARCHAR(30));

INSERT INTO raw_cust (1,'1356,122,20061009,abc');