You need to sign in to do that
Don't have an account?
James George 717
Help needed on Dynamic List variable in Database.QueryLocator batch process
Hi Friends,
Help me why I'm not able to pass List in the below code, it compiles but always returns none and the execute method never executes if the value is List.
Help me why I'm not able to pass List in the below code, it compiles but always returns none and the execute method never executes if the value is List.
public Database.QueryLocator start(Database.BatchableContext bc) { List<String> temp = new List<String>(); temp.add('James'); temp.add('George'); String query = 'SELECT Id, FirstName, LastName ' + ' FROM Contact ' + ' WHERE LastName =\'' + temp + '\'' ; return Database.getQueryLocator(query); } public void execute(Database.BatchableContext bc, List<Contact> scope){ // process each batch of records System.debug('Executing execute---->'); }
Log shows this
|SOQL_EXECUTE_BEGIN|[43]|Aggregations:0|SELECT Id, FirstName, LastName FROM Contact WHERE LastName ='(James, George)'
Appreciating any help.
Thanks,
James
I think your query is not framing correct
Try replacing your query with Code
If it hepls ,Please mark it as best answer!
Thanks!
All Answers
I think your query is not framing correct
Try replacing your query with Code
If it hepls ,Please mark it as best answer!
Thanks!
You can take reference from the below code and you can use IN operator instead of that.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All of your responses are correct, since Abhinav responsded first I marked his answer as best.
Thanks again,
James