Setting the Attribute Values of a Structured UDT Result | Teradata Vantage - Setting the Attribute Values of a Structured UDT Result - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
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);

    ...
}