I am developing middleware services and would like to externalize all dynamic SQL from the service code.

I am developing middleware services and would like to externalize all dynamic SQL from the service code. This is in the context of a migration from 2-Tier architecture to 3-Tiers. One of the issues I am facing is that the original code is "polluted" with loads of dynamic SQL strings, which most of the time correspond to where clauses. Sometimes the same queries are repeated over and over again with only slight variations in the where clause. I want to remove the SQL strings from the code altogether, and instead use a templating engine such as SynMustache to generate the dynamic SQL. From my understanding, SynMustache templates can be compiled ahead of time, so the performance hit should be minimal. Is this the right way to go? Any advicee on this?

Edit: To refocus the discussion from "it's not necessary" to "how to accomplish this in Delphi". I am a developer with a strong Java background. In the Java world you have a framework called MyBatis, which precisely works in this way (see http://www.mybatis.org/mybatis-3/sqlmap-xml.html and http://www.mybatis.org/velocity-scripting/). I have had great success using myBatis in production sites with hundreds of users. This is exactly what I want to reproduce with SynMustache. Obviously starting with smaller ambitions than what MyBatis provides out of the box.

Comments