The mi_fp_retprec() function

The mi_fp_retprec() accessor function obtains the precision of a return value of a user-defined function from its associated MI_FPARAM structure.

Syntax

mi_integer mi_fp_retprec(fparam_ptr, ret_pos)
   MI_FPARAM *fparam_ptr;
   mi_integer ret_pos;
fparam_ptr
A pointer to the associated MI_FPARAM structure.
ret_pos
The index position into the return-precision array for the return value whose precision you want. For user-defined functions, the only valid value is 0.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_fp_retprec() function obtains the precision of the routine return value at position ret_pos from the MI_FPARAM structure that fparam_ptr references.

The precision is an attribute of the data type that represents the total number of digits the routine return value can hold, as follows.
DECIMAL, MONEY
Number of significant digits in the fixed-point or floating-point (DECIMAL) column
DATETIME, INTERVAL
Number of digits that are stored in the date and/or time column with the specified qualifier
Character, Varying-character
Maximum number of characters in the column

If you call mi_fp_retprec() on some other data type, the function returns zero.

The MI_FPARAM structure stores information about the precision of function return values in the zero-based return-precision array. To obtain information about the nth return value, use a ret_pos value of n-1. For example, the following call to mi_fp_retprec() obtains the precision for the first return value of the my_func() user-defined function, with which fparam1 is associated:
mi_integer my_func(..., fparam1)
   ...
   MI_FPARAM *fparam1;
{
   mi_integer ret_prec;
   ...
   ret_prec = mi_fp_retprec(fparam1, 0);
Important: C user-defined functions always have only one return value.

For more information about return-value information in an MI_FPARAM structure or about the precision of a fixed-point data type, see the HCL OneDB™ DataBlade® API Programmer's Guide.

Return values

>=0
The precision, in number of digits, of the fixed-point or floating-point return value at position ret_pos.
MI_ERROR
The function was not successful.