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_end_tran

Description

This function is used to perform a commit or rollback on the current transaction. At this point, all open request handles are terminated and the connection to the database server is disabled. However, even after the connection to the server is disabled, the connection handle remains valid. This is the same state as one in which one connection handle has been assigned by the cci_connect() function. The transaction is committed if the type is set to CCI_TRAN_COMMIT; and is rolled back if it is set to CCI_TRAN_ROLLBACK.

Syntax

int cci_end_tran(int conn_handle, char type, T_CCI_ERROR *err_buf)

  • conn_handle : (IN) Connection handle
  • type : (IN) CCI_TRAN_COMMIT or CCI_TRAN_ROLLBACK
  • err_buf : (OUT) Database error buffer
Return Value
  • Error code (0 : success)
Error Code
  • CCI_ER_CON_HANDLE
  • CCI_ER_DBMS
  • CCI_ER_COMMUNICATION
  • CCI_ER_TRAN_TYPE
Remark

Auto-commit mode is supported for SELECT statements. To apply this mode, you must add SELECT_AUTO_COMMIT=ON to the cubrid_broker.conf file. However, auto-commit is performed only at the point at which the result set for all n query statements is fetched from the server when there are n prepared statements. An example is as follows:

Example 1

$sql1 = "select * from db_user";

$sql2 = "select * from db_class where owner_name = ?";

 

$result = cubrid_execute($con, $sql1);  // 1 select handle. fetch completed - autocommit

if ($result) {

  while ($row = cubrid_fetch ($result))

    {

      echo ($row[0]);

 

      $req = cubrid_prepare ($con, $sql2);

      cubrid_bind ($req, 1, $row[0]);

      $res = cubrid_execute ($req);   // 1 select handle. fetch completed - autocommit

    }

}

Example 2

$sql1 = "select * from db_user";

$sql2 = "select * from db_class where owner_name = ?";

 

$req = cubrid_prepare ($con, $sql2);

$result = cubrid_execute($con, $sql1);  // 2 handle. fetch completed for only 1 hanlde - no autcommit

if ($result) {

  while ($row = cubrid_fetch ($result))

    {

      echo ($row[0]);

 

      cubrid_bind ($req, 1, $row[0]);

      $res = cubrid_execute ($req);   // fetch completed for all select handles - autocommit

    }

}

Example 3

$sql1 = "select * from db_user";

$sql2 = "insert into a values (?)";

 

$result = cubrid_execute($con, $sql1);  // 1 select handle. fetch completed - autocommit

if ($result) {

  while ($row = cubrid_fetch ($result))

    {

      echo ($row[0]);

 

      $req = cubrid_prepare ($con, $sql2);

      cubrid_bind ($req, 1, $row[0]);

      $res = cubrid_execute ($req);    // no autocommit for insert

    }

}

Example 4

$sql1 = "select * from db_user";

$sql2 = "insert into a values (?)";

 

$req = cubrid_prepare ($con, $sql2);

$result = cubrid_execute($con, $sql1);  // no autocommit for insert because no fetch

if ($result) {

  while ($row = cubrid_fetch ($result))

    {

      echo ($row[0]);

 

      cubrid_bind ($req, 1, $row[0]);

      $res = cubrid_execute ($req);   // no autocommit for insert

    }

}