gpt4 book ai didi

c++ - 在 SQLite 中迭代一个 select 语句

转载 作者:搜寻专家 更新时间:2023-10-31 00:39:33 25 4
gpt4 key购买 nike

我准备了一条选择语句。

sqlite3_prepare(db, "SELECT symbol,image FROM test WHERE template=? AND field=?", -1, &stmt, 0);
sqlite3_bind_text16(stmt, 1, pParams->pszFile, -1, SQLITE_STATIC);
sqlite3_bind_text16(stmt, 2, pParams->pszFieldId, -1, SQLITE_STATIC);

如何迭代结果?

最佳答案

int rc = sqlite3_prepare(db, "SELECT symbol,image FROM test WHERE template=? AND field=?", -1, &stmt, 0);
sqlite3_bind_text16(stmt, 1, pParams->pszFile, -1, SQLITE_STATIC);
sqlite3_bind_text16(stmt, 2, pParams->pszFieldId, -1, SQLITE_STATIC);

if(rc != SQLITE_OK)
{
fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(db));
return;
}
rc = sqlite3_step(stmt);
int ncols = sqlite3_column_count(stmt);

while(rc == SQLITE_ROW)
{

for(i=0; i < ncols; i++)
{
fprintf(stderr, "'%s' ", sqlite3_column_text(stmt, i));
}

fprintf(stderr, "\n");
rc = sqlite3_step(stmt);
}

sqlite3_finalize(stmt);

关于c++ - 在 SQLite 中迭代一个 select 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16030003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com