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

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
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_2 using t1.var_char_col and t2.decimal_col as parameters and DECIMAL(10,6) as the implicitly specified return data type because the data type for column t2.decimal_col is DECIMAL(10,6).

     SELECT (udf_2 (t1.var_char_col, t2.decimal_col)
     RETURNS STYLE t2.decimal_col);

The following example invokes udf_3 using t1.var_char_col and t2.decimal_col as parameters and VARCHAR(40) CHARACTER SET UNICODE as the implicitly specified return data type because the data type for column t1.var_char_col is VARCHAR(40) CHARACTER SET UNICODE.

     SELECT (udf_3 (t1.var_char_col, t2.decimal_col)
     RETURNS STYLE t1.var_char_col);

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

     SELECT udt_col.(method_2(t2.decimal_col)
     RETURNS STYLE t2.decimal_col);