← Back to Stormify Documentation
KDBC
Unified C Database Connectivity — SQLite, PostgreSQL, MariaDB, Oracle, MSSQL
Loading...
Searching...
No Matches
Batch Execution

Functions

int kdbc_add_batch (kdbc_stmt *stmt)
 Add current parameters as a batch entry.
int kdbc_execute_batch (kdbc_stmt *stmt)
 Execute all batched parameter sets.

Detailed Description

Execute multiple parameter sets in a single statement.

kdbc_stmt *stmt = kdbc_prepare(conn, "INSERT INTO t (val) VALUES (?)");
for (int i = 0; i < 100; i++) {
kdbc_bind_int(stmt, 1, i);
}
int total = kdbc_execute_batch(stmt);
int kdbc_add_batch(kdbc_stmt *stmt)
Add current parameters as a batch entry.
int kdbc_execute_batch(kdbc_stmt *stmt)
Execute all batched parameter sets.
void kdbc_stmt_close(kdbc_stmt *stmt)
Close a prepared statement and free resources.
kdbc_stmt * kdbc_prepare(kdbc_conn *conn, const char *sql)
Prepare a SQL statement.
int kdbc_bind_int(kdbc_stmt *stmt, int idx, int val)
Bind a 32-bit integer parameter.
struct kdbc_stmt kdbc_stmt
Opaque prepared statement handle.
Definition kdbc.h:44

Function Documentation

◆ kdbc_add_batch()

int kdbc_add_batch ( kdbc_stmt * stmt)

Add current parameters as a batch entry.

After calling this, bind new parameter values and call again for the next row. Finally call kdbc_execute_batch() to execute all rows.

Parameters
stmtA prepared statement with parameters bound.
Returns
KDBC_OK or KDBC_ERROR.

◆ kdbc_execute_batch()

int kdbc_execute_batch ( kdbc_stmt * stmt)

Execute all batched parameter sets.

Parameters
stmtA prepared statement with batched entries.
Returns
Total number of affected rows, or KDBC_ERROR on failure.