Example: Function Mapping with Scalar Subquery (SSQ) Substitution that Includes a System Variable - 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 function mapping definition sessionize_fm specifies a TIMEOUT parameter derived from a scalar subquery that includes the system variable USER.

If TIMEOUT is not specified during function processing, the column value is resolved by processing the scalar subquery:

SELECT timeout FROM ssqtbl WHERE username=USER
CREATE FUNCTION MAPPING sessionize_fm FOR sessionize SERVER coprocessor
USING
InputTable IN TABLE,
ModelTable IN TABLE,
ClusterTable OUT TABLE,
TIMECOLUMN,
TIMEOUT(SELECT timeout FROM ssqtbl WHERE username=USER),
CLICKLAG,
EMITNULL;