Bra*_*son 11
sqlite3_finalize()完成语句后,可以使用该函数,因为您执行了如下所示的一次性查询:
const char *sql = "SELECT COUNT(*) FROM bonds WHERE molecule=? AND structure=?";
sqlite3_stmt *bondCountingStatement;
unsigned int totalBondCount = 0;
if (sqlite3_prepare_v2(database, sql, -1, &bondCountingStatement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(bondCountingStatement, 1, databaseKey);
sqlite3_bind_int(bondCountingStatement, 2, numberOfStructureBeingDisplayed);
if (sqlite3_step(bondCountingStatement) == SQLITE_ROW)
{
totalBondCount = sqlite3_column_int(bondCountingStatement, 0);
}
else
{
}
}
sqlite3_finalize(bondCountingStatement);
Run Code Online (Sandbox Code Playgroud)
或者如果您已完成准备好的声明,您将永远不再需要(可能是因为您在退出应用程序时正在清理).
如果您创建了一个您想要反复使用的语句(出于性能原因,因为准备语句的成本相当昂贵),您可以使用sqlite3_reset()重置查询以便再次使用它.在您决定永远不想重复使用该语句之前,您不希望在这种情况下最终确定(同样,通常这是在您的应用程序或特定对象的拆除期间).
仅在最后重置语句的查询示例如下:
sqlite3_bind_text(insertMoleculeSQLStatement, 1, [filename UTF8String], -1, SQLITE_TRANSIENT);
int success = sqlite3_step(insertMoleculeSQLStatement);
// Because we want to reuse the statement, we reset it instead of finalizing it.
sqlite3_reset(insertMoleculeSQLStatement);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8732 次 |
| 最近记录: |