Allocating the returnValue Buffer - 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ā„¢

Before calling FNC_GetArrayElements, you must allocate the buffer pointed to by returnValue using the C data type that maps to the underlying type of the element. Be sure to allocate the buffer for the number of elements which has been requested. For example, if the underlying type of the element is an SQL INTEGER data type, declare the buffer like this:

INTEGER value;

If the element type is a distinct type, allocate a buffer using the C data type that the distinct type represents. For example, if the element is a distinct type that represents an SQL SMALLINT data type, declare the buffer like this:

SMALLINT value;

If the underlying type of the element is a character string, FNC_GetArrayElements returns a null-terminated character string. The buffer you define must be large enough to accommodate null termination.

If the element type is a structured type, FNC_GetArrayElements returns a UDT handle. To get descriptive information on the attributes of the structured type, pass the UDT handle to FNC_GetStructuredAttributeInfo. For more information, see FNC_GetStructuredAttributeInfo [Deprecated].

To guarantee that the value you pass in for the returnValueBufSize argument matches the length of the data type, use the data type length macros defined in sqltypes_td.h. For UDT element types, use the macro SIZEOF_UDT_HANDLE in calculating the total size of the returnValue buffer since UDT handles are returned. For a list of the data type length macros, see FNC_GetStructuredAttribute.

Be sure to release allocated resources once you have processed the data.