Hi,
I'm discovering/using sqlite3 since three days, and I got a problem
that I don't understand. I have this code :
bool
DataTable_manager::searchByTags(const std::vector <std::string>
&tags_list) {
int rc;
sqlite3_stmt *stmt;
for (auto & tag : tags_list)
{
std::cout << tag << std::endl;
Sqlite3::insertQueryAndGetResults(database, "SELECT * FROM
__TAGS_TABLE__ WHERE TAG = '"+tag+"'", stmt);
do
{
rc = sqlite3_step(stmt);
// std::cout << "ok" << std::endl;
std::cout << sqlite3_column_text (stmt, 0) <<","
<<sqlite3_column_text (stmt, 2) << std::endl;
} while(rc == SQLITE_ROW); }
for information, .schema __TAGS_TABLE__ returns :
CREATE TABLE __TAGS_TABLE__ (TAG_ID INTEGER PRIMARY KEY AUTOINCREMENT,
FILE_ID INT NOT NULL, TAG TEXT NOT NULL);
In __TAGS_TABLE__ I have these two entries : :
1|...
44|2|tag01
45|3|tag02
...
so, somehwere in my code, if I want to search inside that table the
entry where TAG are tag01 and tag02, I create a std::vector and
push_back two strings and I use my function searchByTags,
std::vector <std::string> test_vector;
test_vector.push_back("tag01");
test_vector.push_back("tag02");
dataTable_manager.searchByTags(test_vector);
the problem is, I get this :
tag01
44,tag01
so tag02 is missing. However, if I comment the line,
// std::cout << sqlite3_column_text (stmt, 0) <<","
<<sqlite3_column_text (stmt, 2) << std::endl;
and uncomment
std::cout << "ok" << std::endl;
I get this :
tag01
ok
ok
tag02
ok
ok
for me (I'm not an expert, doing stuff on free time), it's
sound to be a bug, because (for me) it seems that sqlite3_column_text()
force to exit the loops do and for. I don't know if I mess something or
what.
regards,
/nicoo
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users