# CassBatch

### struct CassBatch

A group of statements that are executed as a single batch.

**Note:** Batches are not supported by the binary protocol version 1. 

### Public Types

### enum CassBatchType

*Values:*

### Public Functions

### [CassBatch](#_CPPv49CassBatch) \*cass_batch_new([CassBatchType](#_CPPv4N9CassBatch13CassBatchTypeE) type)

Creates a new batch statement with batch type.

#### SEE ALSO
[cass_batch_free()](#struct_cass_batch_1ad994d8d6b7ea78c38e7d1ab7f952946c)

* **Parameters:**
  **type** – **[in]** 
* **Returns:**
  Returns a batch statement that must be freed.

### void cass_batch_free([CassBatch](#_CPPv49CassBatch) \*batch)

Frees a batch instance. Batches can be immediately freed after being executed.

* **Parameters:**
  **batch** – **[in]** 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_keyspace([CassBatch](#_CPPv49CassBatch) \*batch, const char \*keyspace)

Sets the batch’s keyspace. When using protocol v5 or greater it overrides the session’s keyspace for the batch.

**Note:** If not set explicitly then the batch will inherit the keyspace of the first child statement with a non-empty keyspace.

**Warning:** This function is not yet implemented.

* **Parameters:**
  * **batch** – **[in]** 
  * **keyspace** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_keyspace_n([CassBatch](#_CPPv49CassBatch) \*batch, const char \*keyspace, size_t keyspace_length)

Same as [cass_batch_set_keyspace()](#struct_cass_batch_1aa0dd07ca689e24069a9ade1e71261162), but with lengths for string parameters.

**Warning:** This function is not yet implemented.

#### SEE ALSO
[cass_batch_set_keyspace()](#struct_cass_batch_1aa0dd07ca689e24069a9ade1e71261162)

* **Parameters:**
  * **batch** – **[in]** 
  * **keyspace** – **[in]** 
  * **keyspace_length** – **[in]** 
* **Returns:**
  same as [cass_batch_set_keyspace()](#struct_cass_batch_1aa0dd07ca689e24069a9ade1e71261162)

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_consistency([CassBatch](#_CPPv49CassBatch) \*batch, [CassConsistency](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassConsistency.md#_CPPv415CassConsistency) consistency)

Sets the batch’s consistency level

* **Parameters:**
  * **batch** – **[in]** 
  * **consistency** – **[in]** The batch’s write consistency. 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_serial_consistency([CassBatch](#_CPPv49CassBatch) \*batch, [CassConsistency](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassConsistency.md#_CPPv415CassConsistency) serial_consistency)

Sets the batch’s serial consistency level.

**Default:** Not set

* **Parameters:**
  * **batch** – **[in]** 
  * **serial_consistency** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_timestamp([CassBatch](#_CPPv49CassBatch) \*batch, [cass_int64_t](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.BasicTypes.md#_CPPv412cass_int64_t) timestamp)

Sets the batch’s timestamp.

* **Parameters:**
  * **batch** – **[in]** 
  * **timestamp** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_request_timeout([CassBatch](#_CPPv49CassBatch) \*batch, [cass_uint64_t](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.BasicTypes.md#_CPPv413cass_uint64_t) timeout_ms)

Sets the batch’s timeout for waiting for a response from a node.

**Default:** Disabled (use the cluster-level request timeout)

#### SEE ALSO
cass_cluster_set_request_timeout() 

* **Parameters:**
  * **batch** – **[in]** 
  * **timeout_ms** – **[in]** Request timeout in milliseconds. Use 0 for no timeout or CASS_UINT64_MAX to disable (to use the cluster-level request timeout). 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_is_idempotent([CassBatch](#_CPPv49CassBatch) \*batch, [cass_bool_t](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.BasicTypes.md#_CPPv411cass_bool_t) is_idempotent)

Sets whether the statements in a batch are idempotent. Idempotent batches are able to be automatically retried after timeouts/errors and can be speculatively executed.

#### SEE ALSO
cass_cluster_set_constant_speculative_execution_policy() 

#### SEE ALSO
cass_execution_profile_set_constant_speculative_execution_policy() 

* **Parameters:**
  * **batch** – **[in]** 
  * **is_idempotent** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_retry_policy([CassBatch](#_CPPv49CassBatch) \*batch, [CassRetryPolicy](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/struct.CassRetryPolicy.md#_CPPv415CassRetryPolicy) \*retry_policy)

Sets the batch’s retry policy.

* **Parameters:**
  * **batch** – **[in]** 
  * **retry_policy** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_custom_payload([CassBatch](#_CPPv49CassBatch) \*batch, const [CassCustomPayload](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/struct.CassCustomPayload.md#_CPPv417CassCustomPayload) \*payload)

Sets the batch’s custom payload.

**Warning:** This function is not yet implemented.

* **Parameters:**
  * **batch** – **[in]** 
  * **payload** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_tracing([CassBatch](#_CPPv49CassBatch) \*batch, [cass_bool_t](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.BasicTypes.md#_CPPv411cass_bool_t) enabled)

Sets whether the batch should use tracing.

* **Parameters:**
  * **batch** – **[in]** 
  * **enabled** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_add_statement([CassBatch](#_CPPv49CassBatch) \*batch, [CassStatement](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/struct.CassStatement.md#_CPPv413CassStatement) \*statement)

Adds a statement to a batch.

* **Parameters:**
  * **batch** – **[in]** 
  * **statement** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_execution_profile([CassBatch](#_CPPv49CassBatch) \*batch, const char \*name)

Sets the execution profile to execute the batch with.

**Note:** NULL or empty string will clear execution profile from batch

#### SEE ALSO
cass_cluster_set_execution_profile() 

* **Parameters:**
  * **batch** – **[in]** 
  * **name** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.

### [CassError](https://cpp-rs-driver.docs.scylladb.com/v1.0.1/api/group.CassError.md#_CPPv49CassError) cass_batch_set_execution_profile_n([CassBatch](#_CPPv49CassBatch) \*batch, const char \*name, size_t name_length)

Same as [cass_batch_set_execution_profile()](#struct_cass_batch_1a6c03497681afa31797dc78cc1f90fc8a), but with lengths for string parameters.

#### SEE ALSO
[cass_batch_set_execution_profile()](#struct_cass_batch_1a6c03497681afa31797dc78cc1f90fc8a)

* **Parameters:**
  * **batch** – **[in]** 
  * **name** – **[in]** 
  * **name_length** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.
