clean some sql queries and add some custom error messages
Merge pull request #36 from SIMS-Topaz/aja/clean_sql_queries

clean some sql queries and add some custom error messages