---
title: "CCI API reference: transactions and session settings"
description: "CCI reference for transactions and sessions: cci_end_tran, savepoints, auto-commit, isolation level, lock timeout and holdability."
url: "https://www.coradb.ai/manual/api/cciapi_transaction.html"
markdown_url: "https://www.coradb.ai/manual/markdown/api/cciapi_transaction.md"
product: "CoraDB"
version: "1.0"
keywords: "cci_end_tran, cci_savepoint, cci_set_autocommit, cci_set_isolation_level, cci_set_lock_timeout, cci_set_db_parameter, cci_set_holdability, coradb cci"
---

# CCI API reference: transactions and session settings

Part of the [CCI API reference](https://www.coradb.ai/manual/api/cciapi.html); see the [CCI overview](https://www.coradb.ai/manual/api/cci.html) for how to build and use CCI programs.

## cci_end_tran

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

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

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_DBMS**
> - **CCI_ER_COMMUNICATION**
> - **CCI_ER_TRAN_TYPE**

You can configure the default value of auto-commit mode by using [CCI_DEFAULT_AUTOCOMMIT](https://www.coradb.ai/manual/admin/config_broker.html#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](https://www.coradb.ai/manual/api/cciapi_transaction.html#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](https://www.coradb.ai/manual/api/cciapi_transaction.html#cci_end_tran) function.

**Parameters**

- `conn_handle`: (IN) Connection handle
- `type`: (IN) **CCI_TRAN_COMMIT** or **CCI_TRAN_ROLLBACK**
- `err_buf`: (OUT) Database error buffer

**Returns:** Error code (0: success)

## cci_get_autocommit

``` c
CCI_AUTOCOMMIT_MODE cci_get_autocommit(int conn_handle)
```

The **cci_get_autocommit** function returns the auto-commit mode currently configured.

> - **CCI_AUTOCOMMIT_TRUE**: Auto-commit mode is ON
> - **CCI_AUTOCOMMIT_FALSE**: Auto-commit mode is OFF
> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_USED_CONNECTION**

**Parameters**

- `conn_handle`: (IN) Connection handle

**Returns:**

## cci_get_db_parameter

``` c
int cci_get_db_parameter(int conn_handle, T_CCI_DB_PARAM param_name, void *value, T_CCI_ERROR *err_buf)
```

The **cci_get_db_parameter** function gets a parameter value specified in the database.

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_PARAM_NAME**
> - **CCI_ER_DBMS**
> - **CCI_ER_COMMUNICATION**
> - **CCI_ER_CONNECT**

The data type of *value* for *param_name* is shown in the table below.

| param_name                      | value type | note     |
|---------------------------------|------------|----------|
| **CCI_PARAM_ISOLATION_LEVEL**   | int \*     | get/set  |
| **CCI_PARAM_LOCK_TIMEOUT**      | int \*     | get/set  |
| **CCI_PARAM_MAX_STRING_LENGTH** | int \*     | get only |
| **CCI_PARAM_AUTO_COMMIT**       | int \*     | get only |

In [cci_get_db_parameter](https://www.coradb.ai/manual/api/cciapi_transaction.html#cci_get_db_parameter) and [cci_set_db_parameter](https://www.coradb.ai/manual/api/cciapi_transaction.html#cci_set_db_parameter), the input/output unit of **CCI_PARAM_LOCK_TIMEOUT** is milliseconds.

> **Warning:**
>


**CCI_PARAM_MAX_STRING_LENGTH** is measured in bytes and it gets a value defined in the **MAX_STRING_LENGTH** broker parameter.

**Parameters**

- `conn_handle`: (IN) Connection handle
- `param_name`: (IN) System parameter name
- `value`: (OUT) Parameter value
- `err_buf`: (OUT) Database error buffer

**Returns:** Error code (0: success)

## cci_get_holdability

``` c
int cci_get_holdability(int conn_handle)
```

Returns the cursor holdability setting value about the result set from the connection handle. When it is 1, the connection is disconnected or the cursor is holdable until the result set is intentionally closed regardless of commit. When it is 0, the result set is closed when committed and the cursor is not holdable. For more details on cursor holdability, see Cursor Holdability.

> - **CCI_ER_CON_HANDLE**

**Parameters**

- `conn_handle`: (IN) Connection handle

**Returns:** 0 (not holdable), 1 (holdable)

## cci_is_holdable

``` c
int cci_is_holdable(int req_handle)
```

The **cci_is_holdable** function returns whether the request handle(req_handle) is holdable or not.

> - 1: holdable
> - 0: not holdable
> - **CCI_ER_REQ_HANDLE**

**See also:** [cci_prepare](https://www.coradb.ai/manual/api/cciapi_query.html#cci_prepare)

**Parameters**

- `req_handle`: (IN) Request handle for the prepared statement

**Returns:**

## cci_savepoint

``` c
int cci_savepoint(int conn_handle, T_CCI_SAVEPOINT_CMD cmd, char* savepoint_name, T_CCI_ERROR *err_buf)
```

The **cci_savepoint** function configures savepoint or performs transaction rollback to a specified savepoint. If *cmd* is set to **CCI_SP_SET**, it configures savepoint and if it is set to **CCI_SP_ROLLBACK**, it rolls back transaction to specified savepoint.

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_COMMUNICATION**
> - **CCI_ER_QUERY_TIMEOUT**
> - **CCI_ER_NO_MORE_MEMORY**
> - **CCI_ER_DBMS**

``` c
con = cci_connect( ... );
... /* query execute */

/* Sets the savepoint named "savepoint1" */
cci_savepoint(con, CCI_SP_SET, "savepoint1", err_buf);

... /* query execute */

/* Rolls back to specified savepoint,"savepoint1" */
cci_savepoint(con, CCI_SP_ROLLBACK, "savepoint1", err_buf);
```

**Parameters**

- `conn_handle`: (IN) Connection handle
- `cmd`: (IN) CCI_SP_SET or CCI_SP_ROLLBACK
- `savepoint_name`: (IN) Savepoint name
- `err_buf`: (OUT) Database error buffer

**Returns:** Error code

## cci_set_autocommit

``` c
int cci_set_autocommit (int conn_handle, CCI_AUTOCOMMIT_MODE  autocommit_mode)
```

The **cci_set_autocommit** function configures the auto-commit mode of current database connection. It is only used to turn ON/OFF of auto-commit mode. When this function is called, every transaction being processed is committed regardless of configured mode.

> **Note:**
> [CCI_DEFAULT_AUTOCOMMIT](https://www.coradb.ai/manual/admin/config_broker.html#cci_default_autocommit) in **coradb_broker.conf** determines the default autocommit mode upon program startup.


> **Note:**
> **CCI_DEFAULT_AUTOCOMMIT**, a broker parameter configured in the **coradb_broker.conf** file, determines whether it is in auto-commit mode upon program startup.


**Parameters**

- `conn_handle`: (IN) Connection handle
- `autocommit_mode`: (IN) Configures the auto-commit mode. It has one of the following value: CCI_AUTOCOMMIT_FALSE or CCI_AUTOCOMMIT_TRUE

**Returns:** Error code (0: success)

## cci_set_db_parameter

``` c
int cci_set_db_parameter(int conn_handle, T_CCI_DB_PARAM param_name, void* value, T_CCI_ERROR *err_buf)
```

The **cci_set_db_parameter** function configures a system parameter. For the type of *value* for *param_name*, see [cci_get_db_parameter](https://www.coradb.ai/manual/api/cciapi_transaction.html#cci_get_db_parameter).

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_PARAM_NAME**
> - **CCI_ER_DBMS**
> - **CCI_ER_COMMUNICATION**
> - **CCI_ER_CONNECT**

**Parameters**

- `conn_handle`: (IN) Connection handle
- `param_name`: (IN) System parameter name
- `value`: (IN) Parameter value
- `err_buf`: (OUT) Database error buffer

**Returns:** Error code (0: success)

## cci_set_holdability

``` c
int cci_set_holdability(int conn_handle,int holdable)
```

Sets whether to enable or disable cursor holdability of the result set from the connection level. When it is 1, the connection is disconnected or the cursor is holdable until the result set is intentionally closed regardless of commit. When it is 0, the result set is closed when committed and the cursor is not holdable. For more details on cursor holdability, see [Cursor holdability](https://www.coradb.ai/manual/sql/transaction.html#cursor-holdability).

> - **CCI_ER_INVALID_HOLDABILITY**

**Parameters**

- `conn_handle`: (IN) Connection handle
- `holdable`: (IN) Cursor holdability setting value (0: not holdable, 1: holdable)

**Returns:** Error Code

## cci_set_isolation_level

``` c
int cci_set_isolation_level(int conn_handle, T_CCI_TRAN_ISOLATION  new_isolation_level, T_CCI_ERROR *err_buf)
```

The **cci_set_isolation_level** function sets the transaction isolation level of connections. All further transactions for the given connections work as *new_isolation_level*.

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_CONNECT**
> - **CCI_ER_ISOLATION_LEVEL**
> - **CCI_ER_DBMS**

**Note** If the transaction isolation level is set by cci_set_db_parameter(), only the current transaction is affected. When the transaction is complete, the transaction isolation level returns to the one set by CAS. You must use **cci_set_isolation_level** () to set the isolation level for the entire connection.

**Parameters**

- `conn_handle`: (IN) Connection handle
- `new_isolation_level`: (IN) Transaction isolation level
- `err_buf`: (OUT) Database error buffer

**Returns:** Error code

## cci_set_lock_timeout

``` c
int cci_set_lock_timeout(int conn_handle, int locktimeout, T_CCI_ERROR * err_buf)
```

The **cci_set_lock_timeout** function specifies the connection lock timeout as milliseconds. This is the same with calling **cci_set_db_parameter** (conn_id, CCI_PARAM_LOCK_TIMEOUT, &val, err_buf). See [cci_set_db_parameter](https://www.coradb.ai/manual/api/cciapi_transaction.html#cci_set_db_parameter).

> - **CCI_ER_CON_HANDLE**
> - **CCI_ER_PARAM_NAME**
> - **CCI_ER_DBMS**
> - **CCI_ER_COMMUNICATION**
> - **CCI_ER_CONNECT**

**Parameters**

- `conn_handle`: (IN) Connection handle
- `locktimeout`: (IN) lock timeout value(Unit: milliseconds).

**Returns:** Error code(0: success)
