Obtain input-parameter information
From a statement descriptor, you can obtain information about an input parameter once an SQL statement has been prepared. An input parameter indicates a value that is provided when the prepared statement executes.
Column information | DataBlade® API accessor function |
---|---|
The number of input parameters in the prepared statement | mi_parameter_count() |
The precision (total number of digits) of the column associated with an input parameter | mi_parameter_precision() |
The scale of a column that is associated with the input parameter | mi_parameter_scale() |
Whether the column associated with each input parameter was defined with the NOT NULL constraint | mi_parameter_nullable() |
The type identifier of the column that is associated with the input parameter | mi_parameter_type_id() |
The type name of the column that is associated with the input parameter | mi_parameter_type_name() |
- UPDATE with or without a WHERE clause
- UPDATE WHERE CURRENT OF
If you attempt to request input-parameter information for other SQL statements, the input-parameter functions in Input-parameter information in the statement descriptor raise an exception.
Input-parameter array | Contents |
---|---|
Parameter-type ID array | Each element is a pointer to a type identifier (MI_TYPEID) that indicates the data type of the input parameter. |
Parameter-type name array | Each element is a pointer to the string name of the data type for each input parameter. |
Parameter-scale array | Each element is the scale of the column associated with the input parameter. |
Parameter-precision array | Each element is the precision of the column associated with the input parameter. |
Parameter-nullable array | Each element is either MI_FALSE or MI_TRUE:
|
All of the input-parameter arrays in the statement descriptor have zero-based indexes. Within the statement descriptor, each input parameter in the prepared statement has a parameter identifier, which is the zero-based position of the input parameter within the input-parameter arrays. When you need information about an input parameter, specify its parameter identifier to one of the statement-descriptor accessor functions in Input-parameter information in the statement descriptor.
1
of
these arrays holds the input-parameter information for the second
input parameter of a prepared statement. MI_STATEMENT *stmt_desc;
MI_TYPEID *param_type;
mi_integer param_nullable;
...
param_type = mi_parameter_type_id(stmt_desc, 1);
param_nullable = mi_parameter_nullable(stmt_desc, 1);
To obtain the number of input parameters in the prepared statement (which is also the number of elements in the input-parameter arrays), use the mi_parameter_count() function.