SQL Definition - 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ā„¢

The default parameter mapping convention for mapping SQL data types to Java data types is simple mapping, where SQL data types map to Java primitives. In this example, the EXTERNAL NAME string does not specify the parameter types, so simple mapping is assumed. The corresponding Java function should also use simple mapping as shown in the subsequent Java Method Implementation section.

DATABASE JUDF;
REPLACE FUNCTION MYSUM(x INTEGER)
        RETURNS INTEGER
        LANGUAGE JAVA
        NO SQL
        CLASS AGGREGATE(200)
        PARAMETER STYLE JAVA
        EXTERNAL NAME 'Sum_JAR:UDFExample.simpleSum';

For object mapping, the EXTERNAL NAME string must specify the phase and context along with the object type. For example:

DATABASE JUDF;
REPLACE FUNCTION MYSUM(x INTEGER)
        RETURNS INTEGER
        LANGUAGE JAVA
        NO SQL
        CLASS AGGREGATE(200)
        PARAMETER STYLE JAVA
        EXTERNAL NAME 'Sum_JAR:UDFExample.simpleSum(com.teradata.fnc.Phase,
com.teradata.fnc.Context[],java.lang.Integer) returns java.lang.Integer';

The corresponding Java UDF definition is:

public static java.lang.Integer simpleSum(com.teradata.fnc.Phase phase
,com.teradata.fnc.Context[] context,java.lang.Integer x)
{
   ...
}

For details about simple mapping and object mapping, see Java Data Types.