Allocate memory for the fetch arrays
The DESCRIBE...INTO statement allocates memory for the sqlda structure and its sqlvar_struct structures. However, it does not allocate memory for the sqldata field of the sqlvar_struct structures. The sqldata field holds the fetch array for a retrieved column. Therefore, you must allocate sufficient memory to each sqldata field to hold the elements of the fetch array.
0 <= FetArrSize <= MAXSMINT
The MAXSMINT value is the maximum amount of the data type that can retrieve. Its value is 32767 bytes (32 KB). If the size of the fetch array is greater than MAXSMINT, automatically reduces its size to 32 KB.
(fetch-array size) = (fetch-buffer size) / (row size)
- fetch-array size
- The size of the fetch array, which the FetArrSize global variable indicates
- fetch-buffer size
- The size of the fetch buffer, which the FetBufSize and BigFetBufSize global variables indicate. For information about the size of the fetch buffer, see Optimize cursor execution.
- row size
- The size of the row to be fetched. To determine the size of the row to be fetched, call the rtypmsize() function for each column of the row. This function returns the number of bytes that are needed to store the data type. For more information about the rtypmsize() function, see HCL OneDB ESQL/C data types.
(FetArrSize * row size) > FetBufSize
FetBufSize = FetArrSize * row size
FetArrSize = MAXSMINT / (row size)