i working with newest Xcode and sqlite3 for 4 days now and im kinda getting crazy with it because i just get creepy behavior.
I do this:
NSString *selectWPIDQuery = [NSString stringWithFormat:@"SELECT ID FROM WORKOUTPLANS WHERE NAME = '%s';", [[aWorkoutPlan name] UTF8String]];
//NSLog(@"%@", [aWorkoutPlan name]);
const char *select_wp_id_query = [selectWPIDQuery UTF8String];
if(sqlite3_open([dbPathString UTF8String], &workoutPlansDB) == SQLITE_OK) {
int index = sqlite3_exec(workoutPlansDB, select_wp_id_query, NULL, NULL, &error);
NSLog(@"Der Index %d", index);
}
The Index here is 0 but 0 doesnt exist. if i execute this query with the firefox plugin sqlite manager (exactly the same query) it delivers me the index 1 and the index 1 is correkt.
Why the hell sqlite3 in xcode gives me a 0??? Thats not correct.
You are using
sqlite3_execincorrectly. It returns a result code, not an index. The result code 0 isSQLITE_OK, whereas result code 1 isSQLITE_ERROR.See the
sqlite3_execdocumentation. You must either provide a callback to get the query results, or use the general purposesqlite3_prepare_v2(),sqlite3_step(), andsqlite3_finalize()API.