Table Function Syntax Elements - Analytics Database - Teradata Vantage

SQL External Routine Programming

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
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™
function_name
Pointer to a C string whose value is the function name in the CREATE FUNCTION definition.
The function can use this name to build error messages.
input_parameter_specification
[Optional] Type and name of an input parameter in the CREATE FUNCTION definition. Each input parameter in the definition must have a corresponding input_parameter_specification. The maximum number of input parameters is 128.
The type is the C type in sqltypes_td.h that corresponds to the SQL data type of input_parameter.
result_specification
Result row argument corresponding to one in the CREATE TABLE or REPLACE TABLE statement.
For a table function with fixed row result specification:
  • The table has a result_specification for each column in the RETURNS TABLE clause of the CREATE TABLE statement.
  • Each type is the C type in sqltypes_td.h that matches the SQL data type of the corresponding column in the RETURNS TABLE clause of the CREATE TABLE statement.
  • Each result is a pointer to a data area big enough for a value of the SQL data type of the corresponding column in the RETURNS TABLE clause of the CREATE TABLE statement.
For a table function with dynamic row result specification:
  • The table has a result_specification for each column in the RETURNS TABLE VARYING COLUMNS clause of the CREATE TABLE statement.
  • Each result is a void pointer, because the data types of the result row arguments are unknown until function invocation.

    While running, the table function can get the data types of the result rows by calling the library function FNC_TblGetColDef.

  • Each result is a pointer to a data area big enough for a value of the SQL data type of the corresponding column in the RETURNS TABLE clause of the CREATE TABLE statement.
indicator_parameter_specification
[Optional] Indicator parameter corresponding to an input parameter. Each input_parameter_specification must have a corresponding indicator_parameter_specification. The input parameters and indicator parameters must be in the same order.
If the value of indicator_parameter is -1, the value of the corresponding input_parameter is null.
If the value of indicator_parameter is 0, the value of the corresponding input_parameter is a non-null value.
indicator_result_specification
[Optional] Indicates whether the table function returns the result corresponding indicator_parameter. Each indicator_parameter_specification must have a corresponding indicator_result_specification. The indicator parameters and indicator result parameters must be in the same order.
If the value of indicator_result is -1, the table function does not return the result the corresponding indicator_parameter.
If the value of indicator_result is 0, the table function returns the result the corresponding indicator_parameter.
For a table function with dynamic result row specification, an indicator_result value of -1 means the corresponding result argument was omitted in the SELECT statement that invoked the table function.
If the table function returns NULL for a result argument, the corresponding indicator_result must have the value -1.
sqlstate
Pointer to a six-character C string that indicates the SQLSTATE value—success, exception, or warning. The first five characters are ASCII and the sixth is the C null character. The string is initialized to '00000', which indicates success.
For more information on SQLSTATE values, see Returning SQLSTATE Values.
m
Number of characters in the function name in the CREATE FUNCTION definition. The ANSI SQL standard defines the maximum value for m as 128. Vantage allows a maximum of 30 characters for a function name.
specific_function_name
Pointer to a C string whose value is the name of the external function being invoked.
If the CREATE FUNCTION statement includes the SPECIFIC clause, specific_function_name is the name in the SPECIFIC clause; otherwise, specific_function_name is the same as function_name.
The function can use this name to build error messages.
l
Number of characters in the name of the external function. The ANSI SQL standard defines the maximum value for m as 128. Vantage allows a maximum of 30 characters for a function name.
error_message
Pointer to a C string whose value is the the error message text.
p
Number of characters in the error message text. The maximum value is 256.