Example: Set the Value of the Elements in Positions [10:15][10:20] of the Array - 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™

In this example, FNC_SetArrayElements is called to set the elements within positions [10:15][10:20] to the value of the newValue argument.

/* This function sets the values of a set of elements. */

void setElements( ARRAY_HANDLE  *myArray,
                  INTEGER        newValue,
                  INTEGER       *result,
                  char           sqlstate[6])
{
    int nullIndicator;
    bounds_t *arrayRange;
    array_info_t arrayInfo;
    bounds_t arrayScope[FNC_ARRAYMAXDIMENSIONS];
    nullIndicator = 0;

    /* Call FNC_GetArrayTypeInfo first to find out the number of */
    /* elements in the array. */
    FNC_GetArrayTypeInfo(*myArray,
                         &arrayInfo,
                         arrayScope);

    arrayRange =
    (bounds_t*)FNC_malloc(sizeof(bounds_t)*arrayInfo.numDimensions);

    /* Set values of arrayRange to correspond to the */
    /* range [10:15][10:20] */

    arrayRange[0].lowerBound = 10;
    arrayRange[0].upperBound = 15;
    arrayRange[1].lowerBound = 10;
    arrayRange[1].upperBound = 20;

    /* Set the element values within the positions [10:15][10:20] to */
    /* the value contained in newValue. */
    FNC_SetArrayElements(*myArray, &arrayRange, &newValue,
       nullIndicator, SIZEOF_INTEGER);
    ...
}