16.20 - Example: Overloaded Function with Distinct Parameter Data 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 C functions I_Sales and D_Sales:

void I_Sales( INTEGER *quantity,
              INTEGER *result,
              char    sqlstate[6] )
{
     ...
}
 
void D_Sales( DECIMAL8 *quantity,
              INTEGER  *result,
              char     sqlstate[6] )
{
     ...
}

The name you use in the CREATE FUNCTION statement for I_Sales can be the same name you use in the CREATE FUNCTION statement for D_Sales, because the data type of the quantity parameter for I_Sales is distinct from the data type of the quantity parameter for D_Sales.

Here are two SQL function definitions that overload the function name Sales:

CREATE FUNCTION Sales(Quantity DECIMAL(15,6))
RETURNS INTEGER
SPECIFIC D_Sales
LANGUAGE C
NO SQL
PARAMETER STYLE TD_GENERAL
EXTERNAL;
   
CREATE FUNCTION Sales(Quantity INTEGER)
RETURNS INTEGER
SPECIFIC I_Sales
LANGUAGE C
NO SQL
PARAMETER STYLE TD_GENERAL
EXTERNAL;