If the prepared statement is SELECT, the T_CCI_COL_INFO struct that stores the column information about the execution result can be obtained by using this function. If it is not SELECT, NULL is returned and the num value becomes 0.
You can access the T_CCI_COL_INFO struct directly to get the column information from the struct, but you can also use a macro to get the information, which is defined as follows. The address of the T_CCI_COL_INFO struct and the column index are specified as parameters for each macro. The macro can be called only for the SELECT query. Note that the validity check is not performed for each parameter entered in each macro. If the return type of the macro is char*, do not free the memory pointer.
Macro |
Return Type |
Meaning |
---|---|---|
CCI_GET_RESULT_INFO_TYPE |
T_CCI_U_TYPE |
column type |
CCI_GET_RESULT_INFO_SCALE |
short |
column scale |
CCI_GET_RESULT_INFO_PRECISION |
int |
column precision |
CCI_GET_RESULT_INFO_NAME |
char* |
column name |
CCI_GET_RESULT_INFO_ATTR_NAME |
char* |
column attribute name |
CCI_GET_RESULT_INFO_CLASS_NAME |
char* |
column class name |
CCI_GET_RESULT_INFO_IN_NON_NULL |
char(0 or 1) |
whether a column is NULL |
T_CCI_COL_INFO* cci_get_result_info(int req_handle, T_CCI_SQLX_CMD *cmd_type, int *num)
col_info = cci_get_result_info (req, &cmd_type, &col_count);
if (col_info == NULL)
{
printf ("get_result_info error: %d, %s\n", cci_error.err_code,
cci_error.err_msg);
goto handle_error;
}
for (i = 1; i <= col_count; i++)
{
printf ("%-12s = %d\n", "type", CCI_GET_RESULT_INFO_TYPE (col_info, i));
printf ("%-12s = %d\n", "scale",
CCI_GET_RESULT_INFO_SCALE (col_info, i));
printf ("%-12s = %d\n", "precision",
CCI_GET_RESULT_INFO_PRECISION (col_info, i));
printf ("%-12s = %s\n", "name", CCI_GET_RESULT_INFO_NAME (col_info, i));
printf ("%-12s = %s\n", "attr_name",
CCI_GET_RESULT_INFO_ATTR_NAME (col_info, i));
printf ("%-12s = %s\n", "class_name",
CCI_GET_RESULT_INFO_CLASS_NAME (col_info, i));
printf ("%-12s = %s\n", "is_non_null",
CCI_GET_RESULT_INFO_IS_NON_NULL (col_info,i) ? "true" : "false");