Example: Overloaded Function - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™

Consider the following overloaded Java methods called get_random in the UDFExample class:

public class UDFExample {

   ...

   public static int get_random( int some_value ) {
     ...
   }
   
   public static int get_random( java.sql.Date some_value ) {
     ...
   }

   ...
   
}

The method names are the same, but the data type of the some_value parameter is distinct.

If the JAR file for the UDFExample class is called UDFExample.jar, the following statement registers UDFExample.jar and the UDFExample class with the database, and creates an SQL identifier called JarUDF for the JAR file:

CALL SQLJ.INSTALL_JAR('CJ!C:\udfsrc\UDFExample.jar','JarUDF',0);

Now consider the following function definitions that overload the scalar UDF name UDF_RAN:

CREATE FUNCTION UDF_RAN(SomeValue INTEGER)
RETURNS INTEGER
LANGUAGE JAVA
NO SQL
PARAMETER STYLE JAVA
EXTERNAL NAME 'JarUDF:UDFExample.get_random(int)';

CREATE FUNCTION UDF_RAN(SomeValue DATE)
RETURNS INTEGER
LANGUAGE JAVA
NO SQL
PARAMETER STYLE JAVA
EXTERNAL NAME 'JarUDF:UDFExample.get_random(java.sql.Date)';