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

Functions

kdbc_stmtkdbc_prepare_call (kdbc_conn *conn, const char *sql)
 Prepare a stored procedure call.
int kdbc_register_out (kdbc_stmt *stmt, int idx)
 Register a parameter as OUT.
int kdbc_call_execute (kdbc_stmt *stmt)
 Execute a callable statement.
int64_t kdbc_call_get_long (kdbc_stmt *stmt, int idx)
 Retrieve an OUT parameter as a 64-bit integer.
const char * kdbc_call_get_string (kdbc_stmt *stmt, int idx)
 Retrieve an OUT parameter as a string.

Detailed Description

Execute stored procedures with IN and OUT parameters.

Uses JDBC-style call syntax: "{CALL proc_name(?, ?)}". The library strips the braces and translates for each database.

kdbc_stmt *stmt = kdbc_prepare_call(conn, "{CALL get_count(?, ?)}");
kdbc_bind_string(stmt, 1, "active");
int64_t count = kdbc_call_get_long(stmt, 2);
kdbc_stmt * kdbc_prepare_call(kdbc_conn *conn, const char *sql)
Prepare a stored procedure call.
int kdbc_register_out(kdbc_stmt *stmt, int idx)
Register a parameter as OUT.
int kdbc_call_execute(kdbc_stmt *stmt)
Execute a callable statement.
int64_t kdbc_call_get_long(kdbc_stmt *stmt, int idx)
Retrieve an OUT parameter as a 64-bit integer.
void kdbc_stmt_close(kdbc_stmt *stmt)
Close a prepared statement and free resources.
int kdbc_bind_string(kdbc_stmt *stmt, int idx, const char *val)
Bind a UTF-8 string parameter.
struct kdbc_stmt kdbc_stmt
Opaque prepared statement handle.
Definition kdbc.h:44

Function Documentation

◆ kdbc_prepare_call()

kdbc_stmt * kdbc_prepare_call ( kdbc_conn * conn,
const char * sql )

Prepare a stored procedure call.

Parameters
connAn open connection.
sqlJDBC-style call syntax, e.g. "{CALL my_proc(?, ?)}".
Returns
A callable statement handle, or NULL on failure.

◆ kdbc_register_out()

int kdbc_register_out ( kdbc_stmt * stmt,
int idx )

Register a parameter as OUT.

Must be called before kdbc_call_execute().

Parameters
stmtA callable statement.
idxParameter index (1-indexed).
Returns
KDBC_OK or KDBC_ERROR.

◆ kdbc_call_execute()

int kdbc_call_execute ( kdbc_stmt * stmt)

Execute a callable statement.

Parameters
stmtA callable statement with all parameters bound/registered.
Returns
1 if the call produced a result set, 0 if not, KDBC_ERROR on failure.

◆ kdbc_call_get_long()

int64_t kdbc_call_get_long ( kdbc_stmt * stmt,
int idx )

Retrieve an OUT parameter as a 64-bit integer.

Parameters
stmtA callable statement after execution.
idxOUT parameter index (1-indexed).
Returns
The integer value.

◆ kdbc_call_get_string()

const char * kdbc_call_get_string ( kdbc_stmt * stmt,
int idx )

Retrieve an OUT parameter as a string.

Parameters
stmtA callable statement after execution.
idxOUT parameter index (1-indexed).
Returns
The string value (valid until kdbc_stmt_close()).