FNC_CheckNullBitVectorの使用例 - Advanced SQL Engine - Teradata Database

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

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
2020年6月
Language
日本語
Last Update
2021-03-30
dita:mapPath
ja-JP/qwr1571437338192.ditamap
dita:ditavalPath
ja-JP/qwr1571437338192.ditaval
dita:id
B035-1147
Product Category
Software
Teradata Vantage

この例では、FNC_GetArrayElementsを呼び出してから、FNC_CheckNullBitVectorを呼び出すことで、構成要素2の値を検査します。

void VerifyArrayLength ( ARRAY_HANDLE  *ary_handle,
                         char           sqlstate[6])
{
    NullBitVecType *NullBitVector;
    array_info_t arrayInfo;
    long nullVecBufSize;
    int presenceBit;
    bounds_t *arrayRange;
    bounds_t arrayScope[FNC_ARRAYMAXDIMENSIONS];
    index_t lastPresentElement;

    /* Call FNC_GetArrayTypeInfo first to find out the number of */
    /* elements in the array. */
    FNC_GetArrayTypeInfo(*ary_handle,
                         &arrayInfo,
                         arrayScope);
    (arrayInfo.totalNumElements % 8 == 0) ?
       (nullVecBufSize = arrayInfo.totalNumElements / 8) :
       (nullVecBufSize = arrayInfo.totalNumElements / 8) + 1;

    /* Allocate a new NullBitVector array. */
    NullBitVector = (NullBitVecType*)FNC_malloc(nullVecBufSize);

    /* Initialize the NullBitVector to default values. */
    memset(NullBitVector, 0, nullVecBufSize);
    arrayRange =
    (bounds_t*)FNC_malloc(sizeof(bounds_t)*arrayInfo.numDimensions);

    /* Set values of arrayRange to correspond to the range [1:2][1:2] */
    arrayRange[0].lowerBound = 1;
    arrayRange[0].upperBound = 2;
    arrayRange[1].lowerBound = 1;
    arrayRange[1].upperBound = 2;

    /* Get elements within the range [1:2][1:2] of myArray. */
    FNC_GetArrayElements(*ary_handle, arrayRange, &result, buffer,
       NullBitVector, &length);

    /* Check the presence bit for element [1][1] */
    presenceBit = FNC_CheckNullBitVector(NullBitVector, 1,
       nullVecBufSize);
    ...
}