Parameter-value length array
The parameter-value length array, lengths, is the sixth argument of the mi_exec_prepared_statement() and mi_open_prepared_statement() functions. Each element of the parameter-value length array is the integer length (in bytes) of the data type for the input-parameter value.
The meaning of the values in the lengths array depends on
the control mode of the input-parameter values, as follows:
- For input-parameter values that are in text representation, the lengths array
lists the lengths of the text strings.
Make sure the lengths value matches the length of the null-terminated string of the input-parameter value (minus the null terminator). Use a library function, such as strlen() or stleng(), to determine the string length.
- For input-parameter values that are in binary representation,
the database server does not need to access the entry of the parameter-value
length array. Lengths are not needed in the following special cases:
- Input parameters whose data types (such as mi_integer) are passed with fixed lengths
- Input parameters with string values are passed in varying-length
structures
A varying-length structure holds its own data length.
Important: Even though there are some cases in which
the database server does not read the length of the input-parameter
value, it is recommended that you always specify lengths to maintain
consistency of code.