KSQL_STMT_ALLOC(3)

NAME
ksql_stmt_alloc - allocate a statement on a database connection

LIBRARY
ksql

SYNOPSIS
#include <ksql.h>
enum ksqlc
ksql_stmt_alloc(struct ksql *sql, struct ksql_stmt **stmt, const char *sqlstmt, size_t id);

DESCRIPTION
The ksql_stmt_alloc function allocates a SQL statement sqlstmt on a database connection sql previously opened with ksql_open(3). It must be matched by a call to ksql_stmt_free(3). Upon success, this will fill in the stmt pointer. The idenitfier id is currently not used.

The ksql_stmt_alloc function handles a locked database (specifically, SQLITE_BUSY, SQLITE_LOCKED, or SQLITE_PROTOCOL) by sleeping for a random interval, then trying again infinitely.

RETURN VALUES
This returns KSQL_MEM on allocation failure, KSQL_NOTOPEN if the database isn't connected, or KSQL_DB if there were errors invoking sqlite3_prepare_v2, otherwise KSQL_OK on success.

SEE ALSO
sqlite3_prepare_v2(3)