17.00 - 17.05 - 例: 配列の位置[2:2][2:2]の要素の値の設定 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL外部ルーチン プログラミング

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
17.05
Published
2020年6月
Content Type
プログラミング リファレンス
Publication ID
B035-1147-170K-JPN
Language
日本語 (日本)

この例では、FNC_SetArrayElementsを呼び出して、位置[2:2][2:2]の構成要素にnewValue引数の値を設定します。

/* 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);
    ...
}