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 |
In CCI, multiple jobs can be processed simultaneously when using DML queries such as INSERT/UPDATE/DELETE. CCI_QUERY_RESULT_RESULT() and cci_execute_batch() functions can be used to execute such batch jobs. Note that prepared statements cannot be used in the cci_execute_batch() function.
Executes sql_stmt as many times as num_sql_stmt specified as a parameter and returns the number of queries executed with the query_result variable. You can use the macro (CCI_QUERY_RESULT_RESULT, CCI_QUERY_RESULT_ERR_MSG, CCI_QUERY_RESULT_STMT_TYPE) available in the cci_execute_array() function to get the information about the execution result. For more information about each macro, see the cci_execute_array() function. 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.
int cci_execute_batch(int conn_handle, int num_sql_stmt, char **sql_stmt, T_CCI_QUERY_RESULT **query_result, T_CCI_ERROR *err_buf)
char **queries;
T_CCI_QUERY_RESULT *result;
int n_queries, n_executed;
...
count = 3;
queries = (char **) malloc (count * sizeof (char *));
queries[0] =
"insert into athlete(name, gender, nation_code, event) values('Ji-sung Park', 'M', 'KOR', 'Soccer')";
queries[1] =
"insert into athlete(name, gender, nation_code, event) values('Joo-young Park', 'M', 'KOR', 'Soccer')";
queries[2] =
"select * from athlete order by code desc for orderby_num() < 3";
//calling cci_execute_batch()
n_executed = cci_execute_batch (con, count, queries, &result, &cci_error);
if (n_executed < 0)
{
printf ("execute_batch: %d, %s ", cci_error.err_code,
cci_error.err_msg);
goto handle_error;
}
printf ("%d statements were executed. ", n_executed);
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;
}