Setting the Attribute Values of a Structured UDT Result | Teradata Vantage - Setting the Attribute Values of a Structured UDT Result - 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™

To set the attribute values of a structured UDT that is defined to be the result of a UDF, follow these steps.

IF the attribute … THEN …
does not represent a LOB Allocate a buffer using the C data type that maps to the underlying type of the attribute.

Place the value of the attribute into the buffer.

Call FNC_SetStructuredAttribute or FNC_SetStructuredAttributeByNdx to set the value of the attribute to the value in the buffer you allocated.

You can also set the attribute to null.

represents a LOB Declare a LOB_RESULT_LOCATOR to hold the locator of the LOB attribute.

Call FNC_GetStructuredResultLobAttribute or FNC_GetStructuredResultLobAttributeByNdx to set the LOB_RESULT_LOCATOR to the locator of the LOB attribute.

Follow the steps in Appending Data to a Large Object Result to append the return data using the LOB locator.

For details on FNC_SetStructuredAttribute, FNC_SetStructuredAttributeByNdx, FNC_GetStructuredResultLobAttribute, and FNC_GetStructuredResultLobAttributeByNdx, see C Library Functions.

The following code excerpt sets the attribute value of a structured UDT:

void setX( UDT_HANDLE *pointUdt,
           INTEGER    *val,
           UDT_HANDLE *resultPoint,
           char        sqlstate[6])
{
    INTEGER x;
    INTEGER newval;
    int nullIndicator;
    int length;
    /* Set the x attribute of the result point. */
    nullIndicator = 0;
    newval = *val;
    FNC_SetStructuredAttribute(*resultPoint, "x", &newval,
                                nullIndicator, SIZEOF_INTEGER);

    ...
}