Example: Variable Reference Table Function - 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 shows a variable reference table function equijoined to another table.

Note the following things about this example:
  • The table function is sent to all AMPs and is passed tbl.c1 from all rows in tbl1; therefore it is a variable mode table function (see “Variable Mode Table Function Body” in Teradata Vantage™ - SQL External Routine Programming , B035-1147 ).
  • The designer of this table function added a third argument to demonstrate that the function can provide some intelligence by not producing any rows unless the condition “equal” is met. For example, if the input argument tbl_l.c1 and the row for value tf2.c1 are not equal, the function does not produce any rows. This code eliminates the need for a subsequent step to filter rows produced by the table function resulting from the WHERE clause condition.
           SELECT *
           FROM tbl_1, TABLE(tudf1(28.8, tbl_1.c1, 'equal')) AS tf2
           WHERE tbl_1.c1 = tf2.c1;