SQL UDF Function Examples | Teradata Vantage - Example: Defining the Function and Query - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

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-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

Consider the following function definition and query:

   CREATE FUNCTION Test.MyUDF (a INT, b INT, c INT)
   RETURNS INT
   LANGUAGE SQL
   CONTAINS SQL
   DETERMINISTIC
   SQL SECURITY DEFINER
   COLLATION INVOKER
   INLINE TYPE 1
   RETURN a + b - c;
   SELECT Test.MyUDF(t1.a1, t2.a2, t3.a3) FROM t1, t2, t3;

The user executing the SELECT statement must have the following privileges:

  • SELECT privilege on tables t1, t2, and t3, their containing databases, or on the columns t1.a1, t2.a2, and t3.a3.
  • EXECUTE FUNCTION privilege on MyUDF or on the database named Test.

The privileges of the creator or owner are not checked since the UDF does not reference any database objects in its definition.