Pergunta

Does anyone know how to check if a statement has been prepared or not? I have searched through the SQLite documentation for statements and searched SO, DreamInCode, and DaniWeb but have found no references to my exact question.

I have a statement that I only call in specific circumstances and I only want to attempt to finalize it if it has been used since program crashes are happening by trying to finalize a statement that has not been used. I would rather use whatever SQLite has built-in instead of extra code but I will do just that if there is no null-checking for statements.

Foi útil?

Solução

The documentation says:

Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.

So just ensure that your sqlite3_stmt* variables are initialized with NULL, and are reset to NULL when finalized.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top