Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## 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 convenient way of running one or more SQL statements without having to write a lot of C code. The UTF-8 encoded SQL statements are passed in as the second parameter to sqlite3_exec(). The statements are evaluated one by one until either an error or an interrupt is encountered, or until they are all done. The 3rd parameter is an optional callback that is invoked once for each row of any query results produced by the SQL statements. The 5th parameter tells where to write any error messages.

The error message passed back through the 5th parameter is held in memory obtained from sqlite3_malloc(). To avoid a memory leak, the calling application should call sqlite3_free() on any error message returned through the 5th parameter when it has finished using the error message.

If the SQL statement in the 2nd parameter is NULL or an empty string or a string containing only whitespace and comments, then no SQL statements are evaluated and the database is not changed.

The sqlite3_exec() interface is implemented in terms of sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize(). The sqlite3_exec() routine does nothing to the database that cannot be done by sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize().

The first parameter to sqlite3_exec() must be an valid and open database connection.

The database connection must not be closed while sqlite3_exec() is running.

The calling function should use sqlite3_free() to free the memory that *errmsg is left pointing at once the error message is no longer needed.

The SQL statement text in the 2nd parameter to sqlite3_exec() must remain unchanged while sqlite3_exec() is running.

Requirements: H12101 H12102 H12104 H12105 H12107 H12110 H12113 H12116 H12119 H12122 H12125 H12131 H12134 H12137 H12138

See also lists of Objects, Constants, and Functions.

This page last modified 2009/08/19 14:11:24 UTC