General Usage Guidelines for CREATE FUNCTION and REPLACE FUNCTION (Table Form) - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

User, Database, or Profile DEFAULT MAP OVERRIDE ON ERROR Option

If the map you specify is not valid for any reason, (such as it does not exist, has not been granted to you, Vantage either substitutes a default map or returns an error, subject to the values of the DEFAULT MAP settings for your PROFILE, USER, or DATABASE.

See the CREATE USER DEFAULT MAP option, CREATE DATABASE DEFAULT MAP option, or CREATE PROFILE DEFAULT MAP option.

Map Used by the Function (Table Form)

The map is one of the following as listed in order of precedence:
  • Map, if specified by the EXECUTE MAP option in the FROM clause of the SELECT statement that runs the table operator. For more information, see Table Operator Syntax.
  • Map, if specified by the EXECUTE MAP option as part of the CREATE FUNCTION statement.
  • User default contiguous map.

Relationship of UDFs, Table UDFs, and External Procedures

UDFs, table UDFs, methods, and external procedures are specific variations of each other and share most properties in common.

Protected and Unprotected Modes

Vantage runs table functions written in SAS in protected mode.

See General Usage Guidelines: CREATE FUNCTION and REPLACE FUNCTION (External Form).

Handling SQL Result Codes

See "UDF Handling of SQL Result Codes" in General Usage Guidelines: CREATE FUNCTION and REPLACE FUNCTION (External Form).

Required Function Attributes

Return value data types do not apply to table UDFs.

Parameter Names and Data Types in CREATE FUNCTION (Table Form)

See Parameter Names and Data Types: CREATE FUNCTION and REPLACE FUNCTION (External Form).

While you can specify the TD_ANYTYPE data type for table function parameters, you cannot specify TD_ANYTYPE as the return data type for a table function.

Unlike the case for the RETURNS TABLE clause, you must include an AS LOCATOR phrase for any LOB parameter data types you specify in the parameters clause of a table function.

Optional Function Characteristics in CREATE TABLE (Function Form)

See "Optional Function Characteristics in CREATE FUNCTION and REPLACE FUNCTION (External Form)" in Using Clauses: CREATE FUNCTION and REPLACE FUNCTION (External Form). Table functions do not support the specification of the RETURNS NULL ON NULL INPUT option.

Table UDF Default Location Paths

See "UDF Default Location Paths" in General Usage Guidelines: CREATE FUNCTION and REPLACE FUNCTION (External Form) for information about the default location of UDF-related information.

Table UDF .so Linkage Information

See "UDF .so Linkage Information" in General Usage Guidelines: CREATE FUNCTION and REPLACE FUNCTION (External Form) for information about .so files for table UDFs.

Restrictions on Calling Table Functions

You can call a table function only in the FROM clause of an SQL SELECT request, which includes calling table functions in the FROM clause of a subquery. Calling a table function from any other clause within a query causes the system to stop the request and returns an error to the requestor.

Restrictions on Declaring an External C++ Table Function

If you specify CPP in the LANGUAGE CLAUSE, then you must declare the main C++ function as extern "C" to make sure that the function name is not converted to an overloaded C++ name. For example:

extern "C"
void my_cpp(long int *input_int, long int *result, char sqlstate[6])
{

Restriction on Using a Table Function to Enforce Row-Level Security

You cannot use a table function to enforce row-level security for a security constraint.