Debugging an SQLite query from a C program -


i have sql table 1 of columns has several comma separated values. code below supposed go through of them , return true if particular value present in list, seems work values other first value in entry. ideas screwed up? query works fine when running directly on database file using sqlite3, i'm sure problem function.

bool group_exists(char *group) {     int retv;     char *param_1, *param_2;     bool exists = false;     sqlite3_stmt *p_stmn;      param_1 = malloc(buffer_size);     param_2 = malloc(buffer_size);      sprintf(param_1, "%s,%%", group);     sprintf(param_2, "%%,%s,%%", group);      sqlite3_prepare_v2(db, "select groups users groups ? or groups ?", -1, &p_stmn, null);     sqlite3_bind_text(p_stmn, 1, param_1, -1, null);     sqlite3_bind_text(p_stmn, 1, param_2, -1, null);     retv = sqlite3_step(p_stmn);      if (retv == sqlite_row) {         exists = true;     } else if (retv != sqlite_done) {         retval_crash();     }      free(param_1);     free(param_2);     sqlite3_finalize(p_stmn);      return exists; } 

make sure bind indexes correct sql parameter.

sqlite3_bind_text(p_stmn, 1, param_1, -1, null); sqlite3_bind_text(p_stmn, 2, param_2, -1, null); 

also when trying debug sqlite sure check result codes make sure successful.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -