Function names need not be unique within a function class; however, functions from two different function classes cannot have the same name within the same database or user. Teradata Database uses the parameter types of identically named functions to distinguish among them, so it is imperative that the parameter types associated with overloaded function names be sufficiently different to be distinct.
The system uses the precedence order for compatible type parameters to determine which function is to be invoked when several functions having the same name must be differentiated by their parameter types.
Teradata Database follows a set of parameter rules to determine the uniqueness of a function name. These rules are provided in the following list:
- The following numeric parameter types listed in order of precedence for determining function uniqueness. For example, a BYTEINT fits into a SMALLINT and a SMALLINT fits into an INTEGER. Conversely, a FLOAT does not fit into an INTEGER without a possible loss of information.The types are distinct and compatible. Types sharing a number are synonyms and are not distinct from one another.
The size specification for DECIMAL and NUMERIC types does not affect the distinctiveness of a function. For example, DECIMAL(8,3) and DECIMAL(6,2) are identical with respect to determining function uniqueness.
- FLOAT, DOUBLEPRECISION, REAL
- The following character parameter types are listed in order of precedence for determining function uniqueness.The types are distinct and compatible. Types sharing a character are synonyms and are not distinct from one another. The length specification of a character string does not affect the distinctiveness of a function. For example, CHARACTER(10) and CHARACTER(5) are identical with respect to determining function uniqueness. CHARACTER SET clauses also have no effect on the determination of function uniqueness.
- VARCHAR, CHARACTERVARYING, LONGVARCHAR
- CHARACTER LARGE OBJECT
- The following graphic parameter types are distinct and compatible. Types sharing a bullet are synonyms and are not distinct from one another.
- VARGRAPHIC LONG VARCHAR CHARACTER SET GRAPHIC
- The following byte parameter types are distinct and compatible:
- BINARY LARGE OBJECT
- All date, time, timestamp, and interval parameter types are distinct.
- If the number of parameters in identically named existing functions is different or if the function parameter types are distinct from one another in at least one parameter, then the function being defined is considered to be unique.
- If more than one function has the same function_name, then you must supply a specific_function_name.
- You can only overload function names within the same class within a given database. For example, you cannot have a scalar function and an aggregate function with the same function_name within the same database.