17.05 - Example: Function Mapping with Scalar Subquery (SSQ) Substitution that Includes a System Variable - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

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

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;