Example: Overloaded Function with Distinct Parameter Data Types - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

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;