Aggregate Function Parameter 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.
aggregation_phase
Current aggregation phrase, which determines how the aggregate function processes the input data.
The aggregation phrase definition is:
typedef enum {
  AGR_INIT    = 1,
  AGR_DETAIL  = 2,
  AGR_COMBINE = 3,
  AGR_FINAL   = 4,
  AGR_NODATA  = 5
} FNC_Phase;
aggregation_phase Value How Function Processes Input Data
AGR_INIT Function allocates and initializes intermediate storage for accumulating summary information.
AGR_DETAIL Function accumulates input data into intermediate storage area for specified group.
AGR_COMBINE Function combines intermediate storage areas for each group being aggregated.
AGR_FINAL Function produces final aggregate result for group.
AGR_NODATA Function produces result for null aggregate set.
function_context
Pointer to the function context structure, the intermediate aggregate storage area for groups on which the aggregate function operates.
The function context structure definition is:
typedef struct FNC_Context_t {
  int         version;
  FNC_flags_t flags;
  void        *interim1;
  int         intrm1_length;
  void        *interim2;
  int         intrm2_length;
  long        group_count;
  long        window_size;
  long        pre_window;
  long        post_window;
} FNC_Context_t;
FNC_Context_t Member Description
version Version of context structure. Current version is 1.
interim1 Pointer to aggregate storage area that saves intermediate results.
intrm1_length Length of interim1.
interim2 Pointer to intermediate storage area to combine with interim1 storage area when value of aggregation_phase is AGR_COMBINE.
intrm2_length Length of interim2.
FNC_Context_t members not defined are reserved for future use.
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
Pointer to a data area big enough to hold the result that the function returns, as defined by the RETURNS clause in the corresponding CREATE FUNCTION 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
Result indicator parameter corresponding to the result.
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.