InterviewSolution
| 1. |
What Is An Sqlite_schema Error, And Why Am I Getting One? |
|
Answer» An SQLITE_SCHEMA error is returned when a prepared SQL statement is no LONGER valid and cannot be executed. When this occurs, the statement must be recompiled from SQL using the sqlite3_prepare() API. An SQLITE_SCHEMA error can only occur when using the sqlite3_prepare(), and sqlite3_step() interfaces to run SQL. You will NEVER receive an SQLITE_SCHEMA error from sqlite3_exec(). Nor will you receive an error if you prepare statements using sqlite3_prepare_v2() INSTEAD of sqlite3_prepare(). The sqlite3_prepare_v2() interface creates a prepared statement that will automatically recompile itself if the schema CHANGES. The easiest way to DEAL with SQLITE_SCHEMA errors is to always use sqlite3_prepare_v2() instead of sqlite3_prepare(). An SQLITE_SCHEMA error is returned when a prepared SQL statement is no longer valid and cannot be executed. When this occurs, the statement must be recompiled from SQL using the sqlite3_prepare() API. An SQLITE_SCHEMA error can only occur when using the sqlite3_prepare(), and sqlite3_step() interfaces to run SQL. You will never receive an SQLITE_SCHEMA error from sqlite3_exec(). Nor will you receive an error if you prepare statements using sqlite3_prepare_v2() instead of sqlite3_prepare(). The sqlite3_prepare_v2() interface creates a prepared statement that will automatically recompile itself if the schema changes. The easiest way to deal with SQLITE_SCHEMA errors is to always use sqlite3_prepare_v2() instead of sqlite3_prepare(). |
|