Small. Fast. Reliable.
Choose any three.
Search for:

SQLite C Interface

One-Step Query Execution Interface

int sqlite3_exec(
  sqlite3*,                                  /* An open database */
  const char *sql,                           /* SQL to be evaluated */
  int (*callback)(void*,int,char**,char**),  /* Callback function */
  void *,                                    /* 1st argument to callback */
  char **errmsg                              /* Error msg written here */
);

The sqlite3_exec() interface is a convenience wrapper around sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize(), that allows an application to run multiple statements of SQL without having to use a lot of C code.

R-09704-29281:[The sqlite3_exec() interface runs zero or more UTF-8 encoded, semicolon-separate SQL statements passed into its 2nd argument, in the context of the database connection passed in as its 1st argument. ] R-55733-20912:[If the callback function of the 3rd argument to sqlite3_exec() is not NULL, then it is invoked for each result row coming out of the evaluated SQL statements. ] R-18567-63872:[The 4th argument to sqlite3_exec() is relayed through to the 1st argument of each callback invocation. ] R-34354-51417:[If the callback pointer to sqlite3_exec() is NULL, then no callback is ever invoked and result rows are ignored. ]

R-41103-34171:[If an error occurs while evaluating the SQL statements passed into sqlite3_exec(), then execution of the current statement stops and subsequent statements are skipped. ] R-15162-34851:[If the 5th parameter to sqlite3_exec() is not NULL then any error message is written into memory obtained from sqlite3_malloc() and passed back through the 5th parameter. ] To avoid memory leaks, the application should invoke sqlite3_free() on error message strings returned through the 5th parameter of sqlite3_exec() after the error message string is no longer needed. R-40244-56906:[If the 5th parameter to sqlite3_exec() is not NULL and no errors occur, then sqlite3_exec() sets the pointer in its 5th parameter to NULL before returning. ]

R-61011-49942:[If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() routine returns SQLITE_ABORT without invoking the callback again and without running any subsequent SQL statements. ]

R-02063-40503:[The 2nd argument to the sqlite3_exec() callback function is the number of columns in the result. ] R-24157-46062:[The 3rd argument to the sqlite3_exec() callback is an array of pointers to strings obtained as if from sqlite3_column_text(), one for each column. ] R-03774-63970:[If an element of a result row is NULL then the corresponding string pointer for the sqlite3_exec() callback is a NULL pointer. ] R-26228-33773:[The 4th argument to the sqlite3_exec() callback is an array of pointers to strings where each entry represents the name of corresponding result column as obtained from sqlite3_column_name(). ]

R-31406-45734:[If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer to an empty string, or a pointer that contains only whitespace and/or SQL comments, then no SQL statements are evaluated and the database is not changed. ]

Restrictions:

See also lists of Objects, Constants, and Functions.