Versions available for this page: CUBRID 8.2.1 | CUBRID 8.3.0 | CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |
If more than one value is bound to the prepared statement, this gets the values of the variables to be bound and executes the query by binding each value to the variable.
To bind the data, call the cci_bind_param_array_size() function to specify the size of the array, bind each value to the variable by using the cci_bind_param_array() function, and execute the query by calling the cci_execute_array() function. The query result will be stored on the array of T_CCI_QUERY_RESULT structures.
You can get three execution results by calling the cci_execute() function. However, the cci_execute_array() function returns the number of queries executed by the query_result variable. You can use CCI_QUERY_RESULT_RESULT, CCI_QUERY_RESULT_ERR_NO, CCI_QUERY_RESULT_ERR_MSG and CCI_QUERY_RESULT_STMT_TYPE macros to get the result of each query. However, note that the validity check is not performed for each parameter entered in the macro. After using the query_result variable, you must delete the query_result by using the cci_query_result_free() function.
|
Marco |
Return Type |
Meaning |
|---|---|---|
|
CCI_QUERY_RESULT_RESULT |
int |
the number of results or error identifier (-1: CAS error, -2: DBMS error) |
|
CCI_QUERY_RESULT_ERR_NO |
Int | error number about query |
|
CCI_QUERY_RESULT_ERR_MSG |
char* |
error message about query |
|
CCI_QUERY_RESULT_STMT_TYPE |
int(T_CCI_CUBRID_STMT enum) |
type of query statement |
If autocommit mode is on, each query in the array is committed after executing.
Caution Caution In the previous version of 2008 R4.3, if the autocommit is on, all queries in the array were committed after all of them are executed.
int cci_execute_array(int req_handle, T_CCI_QUERY_RESULT **query_result, T_CCI_ERROR *err_buf)
char *query =
"update participant set gold = ? where host_year = ? and nation_code = 'KOR'";
int gold[2];
char *host_year[2];
int null_ind[2];
T_CCI_QUERY_RESULT *result;
int n_executed;
...
req = cci_prepare (con, query, 0, &cci_error);
if (req < 0)
{
printf ("prepare error: %d, %s ", cci_error.err_code, cci_error.err_msg);
goto handle_error;
}
gold[0] = 20;
host_year[0] = "2004";
gold[1] = 15;
host_year[1] = "2008";
null_ind[0] = null_ind[1] = 0;
error = cci_bind_param_array_size (req, 2);
if (error < 0)
{
printf ("bind_param_array_size error: %d ", error);
goto handle_error;
}
error =
cci_bind_param_array (req, 1, CCI_A_TYPE_INT, gold, null_ind, CCI_U_TYPE_INT);
if (error < 0)
{
printf ("bind_param_array error: %d ", error);
goto handle_error;
}
error =
cci_bind_param_array (req, 2, CCI_A_TYPE_STR, host_year, null_ind, CCI_U_TYPE_INT);
if (error < 0)
{
printf ("bind_param_array error: %d ", error);
goto handle_error;
}
n_executed = cci_execute_array (req, &result, &cci_error);
if (n_executed < 0)
{
printf ("execute error: %d, %s ", cci_error.err_code,
cci_error.err_msg);
goto handle_error;
}
for (i = 1; i <= n_executed; i++)
{
printf ("query %d ", i);
printf ("result count = %d ", CCI_QUERY_RESULT_RESULT (result, i));
printf ("error message = %s ", CCI_QUERY_RESULT_ERR_MSG (result, i));
printf ("statement type = %d ",
CCI_QUERY_RESULT_STMT_TYPE (result, i));
}
error = cci_query_result_free (result, n_executed);
if (error < 0)
{
printf ("query_result_free: %d ", error);
goto handle_error;
}
error = cci_end_tran(con, CCI_TRAN_COMMIT, &cci_error);
if (error < 0)
{
printf ("end_tran: %d, %s ", cci_error.err_code, cci_error.err_msg);
goto handle_error;
}