ここに示す例は、次のn-D ARRAY定義を基にしています。
/*Oracle-compatible and Teradata syntax respectively: */
CREATE TYPE myArray AS VARRAY(1:20)(1:20) OF integer;
CREATE TYPE myArray AS integer ARRAY[1:20][1:20];
/* This function sets the values of a set of elements from a source */
/* ARRAY myArray1 to the same positions of values in myArray2.*/
void setElements ( ARRAY_HANDLE *myArray1,
ARRAY_HANDLE *myArray2,
INTEGER *result,
char sqlstate[6])
{
bounds_t *arrayRange;
array_info_t arrayInfo;
long length;
long bufferSize = sizeof_integer * 4;
int *resultBuf;
NullBitVecType *NullBitVector;
long nullVecBufSize;
bounds_t arrayScope[FNC_ARRAYMAXDIMENSIONS];
/* Call FNC_GetArrayTypeInfo first to find out the number of */
/* elements in myArray1. */
FNC_GetArrayTypeInfo(*myArray1,
&arrayInfo,
arrayScope);
nullVecBufSize = arrayInfo.totalNumElements;
resultBuf = (int*)FNC_malloc(bufferSize);
arrayRange =
(bounds_t*)FNC_malloc(sizeof(bounds_t)*arrayInfo.numDimensions);
/* Allocate a new NullBitVector to pass to FNC_GetArrayElements. */
NullBitVector = (NullBitVecType*) FNC_malloc (nullVecBufSize);
/* Set all members of NullBitVector to 0. */
memset(NullBitVector, 0, nullVecBufSize);
/* Set values of arrayRange to correspond to the */
/* range [1:2][2:3] */
arrayRange[0].lowerBound = 1;
arrayRange[0].upperBound = 2;
arrayRange[1].lowerBound = 2;
arrayRange[1].upperBound = 3;
/*Get elements within the range [1:2][2:3] of myArray1. */
FNC_GetArrayElements(*myArray1, arrayRange, resultBuf, bufferSize,
NullBitVector, nullVecBufSize, &length);
/* Set the element values within the same positions of myArray2 */
/* with the values from myArray1. */
FNC_SetArrayElementsWithMultiValues(*myArray2, &arrayRange,
(void*)resultBuf, bufferSize, NullBitVector, nullVecBufSize);
...
}