16.20 - Example: Function Selection for Character 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 Find_Text functions and the corresponding specific name as specified in the SPECIFIC clause of CREATE FUNCTION.

Function Name and Parameters Specific Name
Find_Text(SearchedString CHAR(40), Pattern VARCHAR(10)) F1
Find_Text(SearchedString VARCHAR(10), Pattern CHAR(20)) F2
Find_Text(SearchedString CHAR(20), Pattern CHAR(10)) F3

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 …
VARCHAR(40) CHAR(50) invokes the function with the specific name F2.

After testing the first argument, F2 remains on the list.

After testing the second argument, F2 is left (exact match).

The length of character string is not considered, so truncation is possible.

VARCHAR(80) VARCHAR(20) returns an error.

After testing the first argument, F2 remains on the list.

After testing the second argument, nothing remains on the list. F2 is not selected because the function is asking for a VARCHAR and the only option is a CHAR, which is of a lower precedence than the VARCHAR.

Do not use CHAR as a parameter type if you want a function to be found with a VARCHAR argument.