Determine the data type of UDR return values
The database server sets the return-value data type of the user-defined function. Most user-defined functions might need to check the return-value data type but they do not need to set it. The routine manager uses the return-value information to determine how to bind the return value to a return variable or an SQL value.
- Override the expected return type (for type hierarchies).
You can set this return-value data type in the MI_FPARAM structure
- Set the actual length, precision, or scale of the return value.
- Return an SQL NULL value.
- Check the return value of a UDR that you are going to execute with the Fastpath interface and for which you have created a user-allocated MI_FPARAM structure.
If your UDR does not need to perform these tasks, it does not need to modify return-value information in the MI_FPARAM structure.
Return-value array | Contents |
---|---|
Return-type array | Each element is a pointer to a type identifier (MI_TYPEID) that indicates the data type of the return value. |
Return-length array | Each element is the integer length of the data type for each return value. |
Return-scale array | Each element is the integer scale in the fixed-point return value. |
Return-precision array | Each element is the integer precision of the fixed-point or floating-point return value. |
Return-null array | Each element has either of the following values:
|
Use the appropriate MI_FPARAM accessor function in Return-value information in the MI_FPARAM structure to access the desired return-value array.
0
of
these arrays holds the return-value information for the first (and
only) return value of a user-defined function.MI_FPARAM *fparam_ptr;
MI_TYPEID *ret_type;
mi_integer ret_len;
...
ret_type = mi_fp_rettype(fparam_ptr, 0);
ret_len = mi_fp_retlen(fparam_ptr, 0);
To obtain the number of return values of the user-defined function, use the mi_fp_nrets() function. However, the number of return values is always 1 for a C user-defined function. The mi_fp_setnrets() function stores the number of return values in the MI_FPARAM structure.