|
|
int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluted */ 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 a lot of C code. The 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 sqlite3_exec() interface is implemented in terms of sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize(). The sqlite3_exec() routine does nothing that cannot be done by sqlite3_prepare_v2(), sqlite3_step(), and sqlite3_finalize(). The sqlite3_exec() is just a convenient wrapper.
| F12101 | The sqlite3_exec() interface evaluates zero or more UTF-8 encoded, semicolon-separated, SQL statements in the zero-terminated string of its 2nd parameter within the context of the sqlite3 object given in the 1st parameter. |
| F12104 | The return value of sqlite3_exec() is SQLITE_OK if all SQL statements run successfully. |
| F12105 | The return value of sqlite3_exec() is an appropriate non-zero error code if any SQL statement fails. |
| F12107 | If one or more of the SQL statements handed to sqlite3_exec() return results and the 3rd parameter is not NULL, then the callback function specified by the 3rd parameter is invoked once for each row of result. |
| F12110 | If the callback returns a non-zero value then sqlite3_exec() will aborted the SQL statement it is currently evaluating, skip all subsequent SQL statements, and return SQLITE_ABORT. (TODO: What happens to *errmsg here? Does the result code for sqlite3_errcode() get set?) |
| F12113 | The sqlite3_exec() routine will pass its 4th parameter through as the 1st parameter of the callback. |
| F12116 | The sqlite3_exec() routine sets the 2nd parameter of its callback to be the number of columns in the current row of result. |
| F12119 | The sqlite3_exec() routine sets the 3rd parameter of its callback to be an array of pointers to strings holding the values for each column in the current result set row as obtained from sqlite3_column_text(). |
| F12122 | The sqlite3_exec() routine sets the 4th parameter of its callback to be an array of pointers to strings holding the names of result columns as obtained from sqlite3_column_name(). |
| F12125 | If the 3rd parameter to sqlite3_exec() is NULL then sqlite3_exec() never invokes a callback. All query results are silently discarded. |
| F12128 | If an error occurs while parsing or evaluating any of the SQL statements handed to sqlite3_exec() then sqlite3_exec() will return an error code other than SQLITE_OK. |
| F12131 | If an error occurs while parsing or evaluating any of the SQL handed to sqlite3_exec() and if the 5th parameter (errmsg) to sqlite3_exec() is not NULL, then an error message is allocated using the equivalent of sqlite3_mprintf() and *errmsg is made to point to that message. |
| F12134 | The sqlite3_exec() routine does not change the value of *errmsg if errmsg is NULL or if there are no errors. |
| F12137 | The sqlite3_exec() function sets the error code and message accessible via sqlite3_errcode() and sqlite3_errmsg(). |
| U12141 | The first parameter to sqlite3_exec() must be an valid and open database connection. |
| U12142 | The database connection must not be closed while sqlite3_exec() is running. |
| U12143 | The calling function is should use sqlite3_free() to free the memory that *errmsg is left pointing at once the error message is no longer needed. |
| U12145 | The SQL statement text in the 2nd parameter to sqlite3_exec() must remain unchanged while sqlite3_exec() is running. |
See also lists of Objects, Constants, and Functions.