Moved hardcoded SQL to stored procedure.
Merge pull request #37 from lostdev/invalid-sql-schema

Merging: Moved hardcoded SQL to stored procedure