Hi
Issues fixed:1) Add proper validation checks for fields.2) Fixed wrong sql generation due to incorrect conditions in template.
Please find attached patch and review.
Thanks,Surinder Kumar