ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs Scylla C/C++ Driver API Documentation CassBatch

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.

Requires Apache Cassandra: 2.0+

Public Functions

CassBatch *cass_batch_new(CassBatchType type)¶

Creates a new batch statement with batch type.

Requires Apache Cassandra: 2.0+

See also

cass_batch_free()

Parameters:

type – [in]

Returns:

Returns a batch statement that must be freed.

void cass_batch_free(CassBatch *batch)¶

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

Requires Apache Cassandra: 2.0+

Parameters:

batch – [in]

CassError cass_batch_set_keyspace(CassBatch *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.

Parameters:
  • batch – [in]

  • keyspace – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_keyspace_n(CassBatch *batch, const char *keyspace, size_t keyspace_length)¶

Same as cass_batch_set_keyspace(), but with lengths for string parameters.

See also

cass_batch_set_keyspace()

Parameters:
  • batch – [in]

  • keyspace – [in]

  • keyspace_length – [in]

Returns:

same as cass_batch_set_keyspace()

CassError cass_batch_set_consistency(CassBatch *batch, CassConsistency consistency)¶

Sets the batch’s consistency level

Requires Apache Cassandra: 2.0+

Parameters:
  • batch – [in]

  • consistency – [in] The batch’s write consistency.

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_serial_consistency(CassBatch *batch, CassConsistency serial_consistency)¶

Sets the batch’s serial consistency level.

Requires Apache Cassandra: 2.0+

Default: Not set

Parameters:
  • batch – [in]

  • serial_consistency – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_timestamp(CassBatch *batch, cass_int64_t timestamp)¶

Sets the batch’s timestamp.

Requires Apache Cassandra: 2.1+

Parameters:
  • batch – [in]

  • timestamp – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_request_timeout(CassBatch *batch, cass_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 cass_batch_set_is_idempotent(CassBatch *batch, cass_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 cass_batch_set_retry_policy(CassBatch *batch, CassRetryPolicy *retry_policy)¶

Sets the batch’s retry policy.

Requires Apache Cassandra: 2.0+

Parameters:
  • batch – [in]

  • retry_policy – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_custom_payload(CassBatch *batch, const CassCustomPayload *payload)¶

Sets the batch’s custom payload.

Requires Apache Cassandra: 2.2+

Parameters:
  • batch – [in]

  • payload – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_add_statement(CassBatch *batch, CassStatement *statement)¶

Adds a statement to a batch.

Requires Apache Cassandra: 2.0+

Parameters:
  • batch – [in]

  • statement – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_execution_profile(CassBatch *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 cass_batch_set_execution_profile_n(CassBatch *batch, const char *name, size_t name_length)¶

Same as cass_batch_set_execution_profile(), but with lengths for string parameters.

See also

cass_batch_set_execution_profile()

Parameters:
  • batch – [in]

  • name – [in]

  • name_length – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_execute_as(CassBatch *batch, const char *name)¶

Sets the name of the user to execute the batch as.

Parameters:
  • batch – [in]

  • name – [in]

Returns:

CASS_OK if successful, otherwise an error occurred.

CassError cass_batch_set_execute_as_n(CassBatch *batch, const char *name, size_t name_length)¶

Same as cass_batch_set_execute_as(), but with lengths for string parameters.

See also

cass_batch_set_execute_as()

Parameters:
  • batch – [in]

  • name – [in]

  • name_length – [in]

Returns:

same as cass_batch_set_execute_as()

Was this page helpful?

PREVIOUS
CassAuthenticatorCallbacks
NEXT
CassCluster
  • Create an issue
  • Edit this page

On this page

  • CassBatch
    • CassBatch
      • CassBatch::cass_batch_new()
      • CassBatch::cass_batch_free()
      • CassBatch::cass_batch_set_keyspace()
      • CassBatch::cass_batch_set_keyspace_n()
      • CassBatch::cass_batch_set_consistency()
      • CassBatch::cass_batch_set_serial_consistency()
      • CassBatch::cass_batch_set_timestamp()
      • CassBatch::cass_batch_set_request_timeout()
      • CassBatch::cass_batch_set_is_idempotent()
      • CassBatch::cass_batch_set_retry_policy()
      • CassBatch::cass_batch_set_custom_payload()
      • CassBatch::cass_batch_add_statement()
      • CassBatch::cass_batch_set_execution_profile()
      • CassBatch::cass_batch_set_execution_profile_n()
      • CassBatch::cass_batch_set_execute_as()
      • CassBatch::cass_batch_set_execute_as_n()
Scylla C/C++ Driver
  • master
    • master
  • C/C++ Driver for ScyllaDB
  • API Documentation
    • CassAggregateMeta
    • CassAuthenticator
    • CassAuthenticatorCallbacks
    • CassBatch
    • CassCluster
    • CassCollection
    • CassColumnMeta
    • CassCustomPayload
    • CassDataType
    • CassErrorResult
    • CassExecProfile
    • CassFunctionMeta
    • CassFuture
    • CassIndexMeta
    • CassInet
    • CassIterator
    • CassKeyspaceMeta
    • CassLogMessage
    • CassMaterializedViewMeta
    • CassMetrics
    • CassNode
    • CassPrepared
    • CassResult
    • CassRetryPolicy
    • CassRow
    • CassSchemaMeta
    • CassSession
    • CassSpeculativeExecutionMetrics
    • CassSsl
    • CassStatement
    • CassTableMeta
    • CassTimestampGen
    • CassTuple
    • CassUserType
    • CassUuid
    • CassUuidGen
    • CassValue
    • CassVersion
    • DseDateRange
    • DseDateRangeBound
    • DseLineString
    • DseLineStringIterator
    • DsePolygon
    • DsePolygonIterator
  • Features
    • Basics
      • Batches
      • Binding Parameters
      • Client-side timestamps
      • Consistency
      • Data Types
      • The date and time Types
      • Futures
      • Handling Results
      • Keyspaces
      • Prepared Statements
      • Schema Metadata
      • Tuples
      • User-Defined Types (UDTs)
      • UUIDs
    • Building
    • Client Configuration
    • Cloud
    • Configuration
      • Retry policies
    • Execution Profiles
    • FAQ
    • Installation
    • Logging
    • Metrics
    • Scylla Specific Features
    • Security
      • SSL
    • Testing
      • Cassandra Cluster Manager (CCM)
    • Tracing
  • DSE Features
    • Authentication
    • Geospatial types
Docs Tutorials University Contact Us About Us
© 2025, ScyllaDB. All rights reserved. | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 28 April 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.6