SQLite Forum

Feature request: Statement context
Login
It would be convenient if it was possible to assign a context pointer to a sqlite3_stmt.

Example usage (pseudo C code):

```
sqlite3_stmt *new_stmt(struct meta_data *ctx) {
  sqlite3_stmt stmt;
  int rc = sqlite3_prepare_v2(...);
  if (rc != SQLITE_OK) { /* error handling */ }

  rc = sqlite3_stmt_set_context(stmt, ctx);
  if (rc != SQLITE_OK) { /* error handling */ }
  return stmt;
}


/* later, iterate over all statements: */
void iterate() {
  sqlite3_stmt *stmt = NULL;
  while ((stmt = sqlite3_stmt_next(stmt))) {
    struct meta_data *ctx = sqlite3_stmt_get_context(stmt);
    /* do stuff with meta data */
  }
}
```