16.20 - Example: Function Selection for Numeric Types - 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)

Consider the following Sales functions and the corresponding specific name as specified in the SPECIFIC clause of the CREATE FUNCTION statement.

Function Name and Parameters Specific Name
Sales(Quantity INTEGER, Profit INTEGER) S1
Sales(Quantity INTEGER, Profit FLOAT) S2
Sales(Quantity FLOAT, ProfiQuantityt INTEGER) S3
Sales(Quantity FLOAT, Profit FLOAT) S4

The following table identifies which function Teradata Database invokes when none of the functions have parameter types that are identical to the corresponding argument types of the function call.

IF the data type of the first argument is … AND the data type of the second argument is … THEN Teradata Database invokes the function with the specific name …
BYTEINT INTEGER S1.

After testing the first argument, S1 and S2 remain on the list.

After testing the second argument, S1 is left.

DECIMAL SMALLINT S3.

After testing the first argument, S3 and S4 remain on the list.

After testing the second argument, S3 remains on the list.

The DECIMAL is converted to a FLOAT and the SMALLINT is converted to an INTEGER before the UDF is called.