I am newbie & trying to create a dynamic querystring on the basis of some conditions, & even when it does not satisfies any condition, the query should be able to run properly with where clause like (where 1 as in other database engines). However, I found that (where 1) is not supported by Apex. So, just wondering If i can use anything else for this situation.
queryString = 'WHERE 1 ';
if(string.isNotEmpty(gravicID)) {
queryString += ' AND (Parameter__c = \'' + 'Test' + '\' AND value__c Like \''+String.escapeSingleQuotes(TestID)+'%\')';
}
if(string.isNotEmpty(AA)) {
queryString += ' AND (Parameter__c = \'' + 'TestName' + '\' AND value__c Like \''+String.escapeSingleQuotes(TestName)+'%\')';
}
And running the SOQL as below,
searchRecordsMap = new Map<String, Container__c>([SELECT Parameter__c, Value__c FROM Container__c queryString ]);