Another thing, what i, sash and Thaddy tried to tell you:
1) Me (with the Link to the sqlite-doc's): That is what sqlite is actually doing BEFORE executing a SQL-Statement. It prepares the statement, and if it is a faulty SQL-Statement you receive an error-code back.
2) Sash: That's what the "Prepare"-Method is actually for (without having checked the source-code, i think it actually calls the function i provided in my link).
3) Thaddy: Use the SQL-Parser he mentioned.
Bottom Line: the easiest method to check if you have a faulty SQL-Statement is to actually run the statement, and rvk showed you how to catch it.