17.10 - Example: Function with TD_ANYTYPE Parameter and Return Type - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

Here is an example of how to declare a Java function that uses a TD_ANYTYPE parameter and return type:

public static java.lang.Object get_smallest(java.lang.Object Obj1,
java.lang.Object Obj2) throws SQL Exception

The following shows the corresponding CREATE FUNCTION statement:

CREATE FUNCTION get_smallest(C1 TD_ANYTYPE, C2 TD_ANYTYPE)
     RETURNS TD_ANYTYPE
     LANGUAGE JAVA
     NO SQL
     PARAMETER STYLE JAVA
     EXTERNAL NAME
     'UDF_JAR:UserDefinedFunctions.get_smallest';

You can also write the CREATE FUNCTION statement as:

CREATE FUNCTION get_smallest(C1 TD_ANYTYPE, C2 TD_ANYTYPE)
     RETURNS TD_ANYTYPE
     LANGUAGE JAVA
     NO SQL
     PARAMETER STYLE JAVA
     EXTERNAL NAME
   'UDF_JAR:UserDefinedFunctions.get_smallest(java.lang.Object, java.lang.Object) returns java.lang.Object';

For an example of a Java UDF that uses a TD_ANYTYPE parameter, see Java Function Using TD_ANYTYPE Parameters.