String str = 'hellotest';
String qry = 'select id,Products__c from Account where End_Date__c > :system.today() and Start_Date__c < :system.today() and IsValid__c = true and Approved__c =' + '\'' + 'Yes' + '\'';
//order by createddate desc
if(!str.equals('NoPromo')){
qry = qry + ' and teststr__c = :str' ;
qry = qry + ' and Offer_Type__c =' + '\'' + 'Promo Code Campaign' + '\'';
}
qry = qry + ' order by createddate desc';
system.debug(qry);
for(Account pc: Database.Query(qry)){}
When i am trying to execute the above logic it is throwing the error
System.QueryException: unexpected token: '('
Can someone please help me where i am doing wrong here