Example: Set the Value of the Element in Position [2:2][2:2] of the Array - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™

In this example, FNC_SetArrayElements is called to set the element in position [2:2][2:2] to the value of the newValue argument.

/* This function receives a new value (newValue) and assigns it to one */
/* particular element in the array. */

void setOneElement( 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 [2:2][2:2] */
    arrayRange[0].lowerBound = 2;
    arrayRange[0].upperBound = 2;
    arrayRange[1].lowerBound = 2;
    arrayRange[1].upperBound = 2;
    /* Set the element in position [2:2][2:2] to the value contained */
    /* in newValue. */
    FNC_SetArrayElements(*myArray, &arrayRange, &newValue,
       nullIndicator, SIZEOF_INTEGER);
    ...
}