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 Implementation section.

DATABASE JUDF;
CREATE FUNCTION extract_field(Text VARCHAR(32000),
                              From_Store INTEGER)
   RETURNS TABLE (Customer_ID INTEGER,
                  Store_ID INTEGER,
                  Item_ID INTEGER)
   LANGUAGE JAVA
   NO SQL
   PARAMETER STYLE JAVA
   EXTERNAL NAME 'UDF_JAR:UserDefinedFunctions.extract_field';

This example shows the SQL definition for a table function with object mapping:

DATABASE JUDF;
CREATE FUNCTION extract_field(Text VARCHAR(32000),
                              From_Store INTEGER)
   RETURNS TABLE (Customer_ID INTEGER,
                  Store_ID INTEGER,
                  Item_ID INTEGER)
   LANGUAGE JAVA
   NO SQL
   PARAMETER STYLE JAVA
   EXTERNAL NAME 'UDF_JAR:UserDefinedFunctions.extract_field(java.lang.String, 
java.lang.Integer, java.lang.Integer[], java.lang.Integer[], java.lang.Integer[]';

The corresponding Java UDF definition is:

public static void extract_field(java.lang.String textstr,
                                 java.lang.Integer from_store,
                                 java.lang.Integer[] cust_id,
                                 java.lang.Integer[] store_id,
                                 java.lang.Integer[] item_id)
{
   ...
}

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