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_prepare

Description

The cci_prepare function prepares SQL execution by acquiring request handle for SQL statements. If a SQL statement consists of multiple queries, the preparation is performed only for the first query. With the parameter of this function, an address to T_CCI_ERROR where connection handle, SQL statement, flag, and error information are stored.

CCI_PREPARE_UPDATABLE, CCI_PREPARE_INCLUDE_OID, or CCI_PREPARE_HOLDABLE can be configured in flag. If CCI_PREPARE_UPDATABLE is configured, updatable resultset is created and CCI_PREPARE_INCLUDE_OID is automatically configured. CCI_PREPARE_UPDATABLE and CCI_PREPARE_HOLDABLE can not be used simultaneously in flag.

The default value of whether to keep result set after commit is cursor holdability. Thus, if you want to configure CCI_PREPARE_UPDATABLE in flag of ci_prepare(), you should call cci_set_holdable(conn, 0) first before calling cci_prepare() so that cursor cannot be maintained.

However, not all updatable resultsets are created even though CCI_PREPARE_UPDATABLE is configured. So you need to check if the results are updatable by using cci_is_updatable after preparation. You can use cci_oid_put or cci_oid_put2 to update result sets.

The conditions of updatable queries are as follows:

  • Must be SELECT.
  • OID can be included in the query result.
  • The column to be updated must be the one that belongs to the table specified in the FROM clause.

If CCI_PREPARE_HOLDABLE is set, a cursor is holded as long as result set is closed or connection is disconnected after the statement is committed (see CUBRID SQL Guide > Transaction Lock >Cursor Holdability).

Syntax

int cci_prepare(int conn_handle, char *sql_stmt, char flag,T_CCI_ERROR *err_buf)

  • conn_handle: (IN) Connection handle
  • sql_stmt: (IN) SQL statement
  • flag : (IN) prepare flag (CCI_PREPARE_UPDATABLE, CCI_PREPARE_INCLUDE_OID, or CCI_PREPARE_HOLDABLE)
  • err_buf: (OUT) Database error buffer
Return Value
  • Success: Request handle ID (int)
  • Failure: Error code
Error Code
  • CCI_ER_CON_HANDLE
  • CCI_ER_DBMS
  • CCI_ER_COMMUNICATION
  • CCI_ER_STR_PARAM
  • CCI_ER_NO_MORE_MEMORY
  • CCI_ER_CONNECT
  • CCI_ER_QUERY_TIMEOUT
  • CCI_ER_LOGIN_TIMEOUT