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

The cci_end_tran function performs 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.

You can configure the default value of auto-commit mode by using CCI_DEFAULT_AUTOCOMMIT (broker parameter) upon startup of an application. If configuration on broker parameter is omitted, the default value is ON; use the cci_set_autocommit() function to change auto-commit mode within an application. If auto-commit mode is OFF, you must explicitly commit or roll back transaction by using the cci_end_tran() function.

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 Codes
  • 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

    }

}