Something like this.
http://code.google.com/p/squiggle-sql/wiki/Tutorial.
This is required for cases where It is required to build complex sql from the user input from UI. Currently in the project I am working is using String Manipulation which looks ugly and is difficult to maintain.