Accessing the Value of a Distinct UDT | Teradata Vantage - Accessing the Value of a Distinct UDT - 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 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);

    ...
}