Destroy A Prepared Statement Object
Captured . SQLite public-domain documentation.
Provenance and reading-copy limits
This is a derived reading copy, not byte-identical replay. Original scripts, styling and diagrams are omitted. Links to retained documents use their reading copies; other links lead to live sources, which may have changed since capture. No external page resources are loaded from the original document.
Original size: 5309 bytes. SHA-256: 6511ba46fa1cc670ad8aa1ef96e9921e0f7890b095d7e9a9f8fe1e8009405d2d.
SQLite C Interface
Destroy A Prepared Statement Object
int sqlite3_finalize(sqlite3_stmt *pStmt);
The sqlite3_finalize() function is called to delete a prepared statement. If the most recent evaluation of the statement encountered no errors or if the statement has never been evaluated, then sqlite3_finalize() returns SQLITE_OK. If the most recent evaluation of statement S failed, then sqlite3_finalize(S) returns the appropriate error code or extended error code.
The sqlite3_finalize(S) routine can be called at any point during the life cycle of prepared statement S: before statement S is ever evaluated, after one or more calls to sqlite3_reset(), or after any call to sqlite3_step() regardless of whether or not the statement has completed execution.
Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
The application must finalize every prepared statement in order to avoid resource leaks. It is a grievous error for the application to try to use a prepared statement after it has been finalized. Any use of a prepared statement after it has been finalized can result in undefined and undesirable behavior such as segfaults and heap corruption.