Example: Invoking a UDF or Method Using a RETURNS Specification - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

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
2024-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™
The table definitions used in this example are:
     CREATE TABLE t1 (
       int_col      INTEGER,
       var_char_col VARCHAR(40) CHARACTER SET UNICODE);
     CREATE TABLE t2 (
       int_col     INTEGER,
       decimal_col DECIMAL (10, 6));
These function definitions are used in this example to identify the TD_ANYTYPE parameters:
     CREATE FUNCTION udf_1(
       A    INTEGER,
       B    TD_ANYTYPE)
       RETURNS TD_ANYTYPE;
     CREATE FUNCTION udf_3(
       A    INTEGER,
       B    TD_ANYTYPE)
       RETURNS TD_ANYTYPE;

The following example invokes udf_1 using t1.int_col and t2.decimal_col as parameters and DECIMAL(10,6) as the explicitly specified return data type.

     SELECT (udf_1 (t1.int_col, t2.decimal_col)
     RETURNS DECIMAL(10,6));

The following example invokes udf_3 using t1.var_char_col and t2.decimal_col as parameters and VARCHAR(40) as the explicitly specified return data type.

     SELECT (udf_3 (t1.var_char_col, t2.decimal_col)
     RETURNS VARCHAR(40) CHARACTER SET LATIN);

The final example invokes method_2 using t2.decimal_col as a parameter and DECIMAL(10,6) as the explicitly specified return data type.

     SELECT udt_col.(method_2(t2.decimal_col)
     RETURNS DECIMAL(10,6));