The mi_parameter_precision() function

The mi_parameter_precision() function obtains the precision of the column associated with the specified input parameter in a prepared statement.

Syntax

mi_integer mi_parameter_precision(stmt_desc, param_id)
   MI_STATEMENT *stmt_desc;
   mi_integer param_id;
stmt_desc
A pointer to the statement descriptor for the prepared statement that contains the input parameter.
param_id
The parameter identifier of the column, which specifies the position of the input parameter in the specified statement descriptor. Input-parameter numbering follows C programming conventions: the first parameter in the statement is at position zero.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_parameter_precision() function obtains the precision of the column that is associated with the param_id input parameter from the statement descriptor that stmt_desc references. This function is an accessor function for a statement descriptor, which describes a prepared statement. The statement descriptor stores information about the precisions of input-parameter columns in the zero-based parameter-precision array. To obtain information about the nth input parameter, use a param_id value of n-1.

The precision is an attribute of the column data type that represents the total number of digits the column associated with an input parameter can hold, as follows.
Data Type Meaning
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_parameter_precision() on an input parameter whose column is some other data type, the function returns zero.

Parameter information is available only for the INSERT and UPDATE statements. Support for the UPDATE statement includes the following forms of UPDATE:
  • UPDATE with or without a WHERE clause
  • UPDATE WHERE CURRENT OF

If you attempt to request parameter information for other SQL statements, mi_parameter_precision() raises an exception.

For more information about input parameters or about the precision of a fixed-point data type, see the Informix® DataBlade® API Programmer's Guide.

Return values

0
indicates that no precision was set for the column of the specified input parameter.
>=0
The precision of the column that is associated with the specified input parameter.
MI_ERROR
The function was not successful.