I need to add another condition to my where cause below
SQL.Add('where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=:DaysParam)');
I need to also add
and (cmcl_bank_cleared <> to_date(’01/01/2011′, ‘mm/dd/yyyy’))
the problem is the single quotes
can i do the following?
SQL.Add('where (cmcl_bank_cleared is not null) AND ');
SQL.Add('(cmcl_bank_cleared <> to_date(' + QuotedStr(01/01/2011) + ', ' + QuotedStr('mm/dd/yyyy') + ')');
SQL.Add('((cmcl_bank_cleared - check_date) >=:DaysParam)');
You can use QuotedStr to build queries, but it’s not the best idea. If any of the input comes from a user, they could theoretically enter strange things that would end up having unwanted effects on your database. This is known as SQL Injection and is a serious security problem for a lot of websites.
The proper and safe way to insert values into the middle of a query like that is to use parameterized queries. Look up the documentation on the Params property of your dataset to learn how it works.