External Stored Procedures That Use TD_ANYTYPE Arguments | Teradata Vantage - External Stored Procedures That Use TD_ANYTYPE Arguments - 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™

You can define external stored procedures with IN, INOUT, or OUT parameters that are of TD_ANYTYPE data type. The TD_ANYTYPE parameter data type can accept any system-defined data type. You cannot use TD_ANYTYPE to represent UDT parameters because UDT parameters are not supported in Java routines.

The parameter attributes and return type are determined at execution time based on the actual arguments passed to the routine. For more information about the TD_ANYTYPE type, see Teradata Vantage™ - Data Types and Literals, B035-1143.

The TD_ANYTYPE parameter is mapped to java.lang.Object in the Java routine. You must specify java.lang.Object as the Java parameter type corresponding to the TD_ANYTYPE parameter in the external stored procedure.

Example: External Stored Procedure with TD_ANYTYPE Parameter Type

Here is an example of how to declare a Java external stored procedure that uses TD_ANYTYPE parameter types:

public static void get_smallest(java.lang.Object C1, java.lang.Object[] C2)

The following shows the corresponding CREATE PROCEDURE statement:

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

The RETURNS and RETURNS STYLE Clauses

When invoking an external stored procedure that is defined with a TD_ANYTYPE OUT parameter, you can specify the RETURNS data type or RETURNS STYLE column expression clauses along with the OUT argument in the CALL statement to indicate the desired return type of the OUT parameter. The column expression can be any valid table or view column reference, and the return data type is determined based on the type of the column.

The RETURNS or RETURNS STYLE clause is not mandatory as long as the procedure also includes a TD_ANYTYPE input parameter. If you do not specify a RETURNS or RETURNS STYLE clause, then the data type of the first TD_ANYTYPE IN or INOUT argument is used to determine the return type of the OUT parameter. For character types, if the character set is not specified as part of the data type, then the default character set is used.

The RETURNS and RETURNS STYLE clauses are only used to set the return type for a TD_ANYTYPE OUT parameter. The data type of a TD_ANYTYPE INOUT parameter is determined by the data type of the corresponding input argument.