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
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
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.

Attribute Represents a LOB Steps
No
  1. Allocate a buffer using the C data type that maps to the underlying type of the attribute.
  2. Place the value of the attribute into the buffer.
  3. Call FNC_SetStructuredAttribute or FNC_SetStructuredAttributeByNdx to set the value of the attribute to the value in the buffer you allocated.
  4. [Optional] Set the attribute to null.
Yes
  1. Declare a LOB_RESULT_LOCATOR to hold the locator of the LOB attribute.
  2. Call FNC_GetStructuredResultLobAttribute or FNC_GetStructuredResultLobAttributeByNdx to set the LOB_RESULT_LOCATOR to the locator of the LOB attribute.
  3. 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);

    ...
}