Example: Invoking Compatible Argument Data Types - 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

In this example, the UDF invocation argument data type (BYTEINT) is not the same as that of the corresponding UDF parameter data type (INTEGER) because the size of the argument data type is less than the UDF parameter data type. However, because the two data types are compatible and a BYTEINT argument can fit inside an INTEGER parameter, this is allowed.

   CREATE FUNCTION test.MyUDF (a INT, b INT, c INT)
   RETURNS INT
   LANGUAGE SQL
   CONTAINS SQL
   DETERMINISTIC
   COLLATION INVOKER
   INLINE TYPE 1
   RETURN a * b * c;
   CREATE TABLE t1 (a1 BYTEINT, b1 INT);
   SELECT test.MyUDF(t1.a1, t1.b1, 2) FROM t1;