16.20 - Calling a Function That is Overloaded - 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)

If several functions have the same name, then Teradata Database uses the following steps to determine which function to invoke.

IF... THEN...
no argument in the function call is the NULL keyword if one of the functions has parameter types that are identical to the corresponding argument types of the function call, then Teradata Database selects that function.
If no function has parameter types that are identical to the corresponding argument types of the function call, then Teradata Database repeats the following test for each argument of the function call, starting with the first (left):
  • If the argument type of the function call fits the corresponding parameter type of any of the functions, in order of compatibility precedence, then keep those functions and eliminate the others.
  • If the argument type of the function call does not fit the corresponding parameter type of any of the functions, in order of compatibility precedence, then return an error.

For more information on the rules of compatible precedence, see Compatible Types.

any argument in the function call is the NULL keyword Teradata Database repeats the following test for each argument of the function call, starting with the first (left):
  • If the argument type of the function call fits the corresponding parameter type of any of the functions, in order of compatibility precedence, then keep those functions and eliminate the others.
  • If the argument is the NULL keyword, then treat the NULL as a wildcard that matches any data type and continue to the next argument. Do not eliminate any function.
  • If the argument type of the function call does not fit the corresponding parameter type of any of the functions, in order of compatibility precedence, return an error.
After testing each argument and not returning an error, Teradata Database uses the following rules:
  • If one function remains, then Teradata Database selects that function.
  • If more than one function remains, then Teradata Database returns an error.

    To avoid this error, you can explicitly cast the keyword NULL to the data type of the corresponding parameter of the overloaded UDF you want to use.

For more information on the rules of compatible precedence, see Compatible Types.