Parameter Passing Convention - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

UDFs support two types of parameter passing conventions.

Parameter Passing Convention Description Usage
Parameter Style SQL Provides a way to pass nulls as input arguments and return a null as the result.
  • Scalar function
  • Aggregate function
  • Table function
Parameter Style TD_GENERAL Does not accept null input arguments and does not return a null result.
  • Scalar function
  • Aggregate function

The parameter passing convention you use to code a UDF must correspond to the parameter passing specification in the CREATE FUNCTION statement for the UDF.

IF CREATE FUNCTION specifies … AND you are writing … THEN use this syntax for function parameters …
PARAMETER STYLE TD_GENERAL a scalar function Scalar Function Parameter Style TD_GENERAL Syntax
an aggregate function Aggregate Function Parameter Style TD_GENERAL Syntax
PARAMETER STYLE SQL or omits the PARAMETER STYLE option a scalar function Scalar Function Parameter Style SQL Syntax
an aggregate function Aggregate Function Parameter Style SQL Syntax
a table function Table Function Syntax

Teradata provides a special UDF input parameter data type called the dynamic user-defined type (UDT). UDFs can specify up to eight dynamic UDT input parameters. A dynamic UDT can accommodate up to 128 attributes, where the data types of the attributes are determined at runtime.

If you consider each attribute of a dynamic UDT as an input parameter, then the number of effective input parameters increases to 1144, where:

(8 dynamic UDT parameters * 128 attributes) + (120 parameters of other data types) = 1144

For details on using dynamic UDTs, see Defining Functions that Use UDT Types.