Accessing the Value of a Distinct UDT | Teradata Vantage - 17.10 - Accessing the Value of a Distinct UDT - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

To access the value of a distinct UDT, follow these steps.

IF the distinct type … THEN …
does not represent a LOB
  1. Allocate a buffer using the C data type that maps to the underlying type of the distinct UDT.
  2. Call FNC_GetDistinctValue to place the value of the UDT into the buffer you allocated.
represents a LOB
  1. Declare a LOB_LOCATOR to hold the locator of the distinct type.
  2. Call FNC_GetDistinctInputLob to set the LOB_LOCATOR to the LOB locator of the distinct UDT.
  3. Follow the steps in Accessing the Value of a Large Object to read the data.

For detailed information on FNC_GetDistinctValue and FNC_GetDistinctInputLob, see C Library Functions.

Here is a code excerpt that shows how to access the value of a distinct type that represents a FLOAT:

void meters_t_toInches( UDT_HANDLE    *metersUdt,
                        FLOAT         *result,
                        char           sqlstate[6])
{
    FLOAT value;
    int length;
    /* Get the value of metersUdt. */
    FNC_GetDistinctValue(*metersUdt, &value, SIZEOF_FLOAT, &length);

    ...
}