sqlite issue using WHERE statement on a varchar field in Objective-C
I have this sql statement SELECT * FROM Language WHERE La开发者_C百科nguageCode=?
where LanguageCode is a varchar(2).
When I use sqlite3-prepare-v2 on that statement I got SQLITE_ERROR but if I use SELECT * FROM Language WHERE LanguageID=?
where LanguageID is the primary key numeric identity field the statement compiles just fine.
Is there any issue filtering by a varchar field using WHERE statement?
Thanks
I think there should be no issue with the where statement by using a varchar field. Maybe you are having problem with passing the parameter. Try to print to NSLog and see the statement that is executed, and execute it with the sqlite command prompt to see if you have return values.
Be sure your ? is wrapped in single quotes.
SQLite should also give you an error string which tell you why there is an error.
Try to call sqlite3_errmsg
and check the error string returned from that call. It should give you a more detailed information about what went wrong.
Claus
精彩评论