17.10 - Example - 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)

The following is an example of using FNC_GetArrayElementCount to retrieve the number of present elements for a 1-D ARRAY:

void getNumAryElts ( ARRAY_HANDLE  *phone_ary,
                     INTEGER       *result,
                     char           sqlstate[6])
{
    int presElementsCount;
    int lastElement[1];

    /* Get the number of elements currently stored in the array. */
    FNC_GetArrayElementCount((*phone_ary), &presElementsCount,
       lastElement);
    *result = presElementsCount;
    ...
}

The following example calls FNC_GetArrayElementCount to retrieve the number of present elements for an n-D ARRAY:

void SeismicStations ( ARRAY_HANDLE  *seismic_ary,
                       INTEGER       *result,
                       char           sqlstate[6])
{
    int presElementsCount;
    int lastElement[FNC_ARRAYMAXDIMENSIONS];
    /* Get the number of readings(elements) of seismic_ary. */
    FNC_GetArrayElementCount((*seismic_ary), &presElementsCount,
       lastElement);
    ...
}