Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

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 | 

cci_execute_array

Description

If more than one value are 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.

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 the following macro to get the information about the execution result. 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

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

Syntax

int cci_execute_array(int req_handle, T_CCI_QUERY_RESULT **query_result, T_CCI_ERROR *err_buf)

  • req_handle : (IN) Request handle of a prepared SQL statement
  • query_result : (OUT) Query results (the number of executed queries)
  • err_buf : (OUT) Database error buffer
Return Value
  • Success : The number of executed queries
  • Failure : Negative number
Error Code
  • CCI_ER_REQ_HANDLE
  • CCI_ER_BIND
  • CCI_ER_DBMS
  • CCI_ER_COMMUNICATION
Example

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\n", 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\n", 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\n", 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\n", error);

      goto handle_error;

    }

 

n_executed = cci_execute_array (req, &result, &cci_error);

  if (n_executed < 0)                                                                                                                       

    {                                                                                                                                       

      printf ("execute error: %d, %s\n", cci_error.err_code,

              cci_error.err_msg);

      goto handle_error;

    }                                                                                                                                       

  for (i = 1; i <= n_executed; i++)                                                                                                         

    {                                                                                                                                       

      printf ("query %d\n", i);

      printf ("result count = %d\n", CCI_QUERY_RESULT_RESULT (result, i));

      printf ("error message = %s\n", CCI_QUERY_RESULT_ERR_MSG (result, i));

      printf ("statement type = %d\n",

              CCI_QUERY_RESULT_STMT_TYPE (result, i));

    }

  error = cci_query_result_free (result, n_executed);

  if (error < 0)                                                                                                                            

    {                                                                                                                                       

      printf ("query_result_free: %d\n", error);

      goto handle_error;                                                                                                                    

    }