Debug sqlite

Is there any way to see what happened? showStatement after sqlite3_prepare_v2 and sqlite3_bind_xxx?

Running this query:

SELECT * 
FROM shows, locations 
WHERE (shows.day_id = 1) 
  AND (shows.id IN (6,7,15,19,23,66)) 
  AND (shows.location_id = locations.id)
ORDER by locations.sort_order

works great in SQLite Manager and in code when I enter it EXACTLY. If, however, I perform parameter substitution, the query does not return results ...

if (sqlite3_open([databasePath UTF8String],&showsDatabase) == SQLITE_OK){
    const char *sqlStatement = "SELECT * FROM shows, locations WHERE (shows.day_id = ?) AND (shows.id IN (?)) AND (shows.location_id = locations.id) ORDER by locations.sort_order";
        sqlite3_stmt *showStatement;
        if(sqlite3_prepare_v2(showsDatabase, sqlStatement, -1, &showStatement, NULL) == SQLITE_OK) {
            sqlite3_bind_int(showStatement, 1, forDay);
            sqlite3_bind_text(showStatement, 2, allFavorites,-1,NULL);
            int error = sqlite3_step(showStatement);
            while(sqlite3_step(showStatement) == SQLITE_ROW) {

...

The problem should lie in the IN part (6.7 ...), without which it works fine.

My debugger shows me that forDay = 1 and that allFavorites = 6,7,15,19,23,66 but error = 101 = sqlite3_step () completed execution = no rows found

The ability to see the variable 'showStatement' will somehow solve the problem, however, the debugger does not report this information

+3
source share
1

IN (?) .

shows.id IN (?, ?, ?, ?, ?, ?) . , , .

+1

Source: https://habr.com/ru/post/1764797/


All Articles