Passing Parameters to an SQL UDF - Analytics Database - Teradata Vantage

SQL Data Definition Language Detailed Topics

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-10-04
dita:mapPath
vuk1628111288877.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
jbg1472252759029
lifecycle
latest
Product Category
Teradata Vantage™

When you pass parameters directly to a UDF, Vantage returns parameter metadata in a Statement Info parcel (see Teradata® Call-Level Interface Version 2 Reference for Mainframe-Attached Systems, B035-2417 for details). The rules for passing parameters to an external UDF or method also apply to SQL UDFs (see Rules for Using SQL UDFs and Function Calling Argument).

In this example, the SQL UDF is not overloaded, so Vantage can resolve the UDF with just a ? parameter passed directly to the UDF. Vantage returns the parameter metadata regarding the UDF parameter in the target position.

SELECT myudf(1, ?)
FROM t1;

In this example, the SQL UDF is overloaded, so you must explicitly cast the ? parameter to an acceptable value to enable the UDF to be resolved in Prepare mode. If you do not specify such a cast, Vantage cannot resolve the UDF, so the request aborts and the system returns an error to the requestor. For the purposes of parameter metadata, the data type field of the returned metadata is the result type of the cast.

SELECT myudf(1, CAST(? AS INTEGER), col3)
FROM t1;