I have searched through all the questions, but did not find an answer yet. The closest I came to was this Passing an array to sqlite WHERE IN clause via FMDB? . However, the answer suggested did not seem to work. The command does not throw any error, however it does not perform the intended operation (e.g. DELETE) either. Here's what I am trying to do :
[myDB executeUpdateWithFormat:@"DELETE FROM table WHERE row_id IN (%@)",rowIdsToBeDeleted];
rowIdsToBeDeleted is a comma seperated NSString containing rowIds as NSNumber objects, e.g.
1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012
I even tried using the executeUpdate, but no luck. Could any of you please help ?
If that method is anything like the NSPredicate syntax, simply remove the parenthesis (they are handled for you (and pass in a collection instead of a string):
NSArray *ids = [rowIdsToBeDeleted componentsSeparatedByString:@","];
[myDB executeUpdateWithFormat:@"DELETE FROM table WHERE row_id IN %@",ids];
Also, usually you pass in an actual collection object (not a string)... above edited to reflect