Just generally, don't write SQL queries as strings. An ORM is one option, language-level extensions another. But for that you need some good macros in your language - or convince the maintainers of your compiler to add it to the language (like Microsoft did in C#).
For example:
So I wonder, is there any way to force programmers into writing secure queries (by not writing queries)? Is ORM the way to go?