Am building a dynamic SOQL where I am using a list of strings that represent record ids, here's an example similar to my class:
String q = '';
q += 'SELECT Id FROM' + object;
q += ' WHERE Id IN :record_ids';
List<sObject> sobjects = Database.query(q);
When record_ids has a single Id in the list it works fine, more then one and it does not bring back any records.
I have tried creating a string based IN in many forms, for example:
record_scope += '\'' + record_id + '\',';
But when I look at the logs instead of ... IN ('00000000000001','00000000000002') I get ... IN ('00000000000001,00000000000002') looks like ' are subtracted for some reason.
Any help will be appreciated.
Cheers
.split()and other methods with no success, when I manually construct the string like this:database.query(... Id IN :('0001','0002','0003') ...)it works fine. But the interesting thing is thatq += ' WHERE Id IN :record_ids';works perfectly fine whenrecord_idsstring list has only one entry, but when it has more no records are returned.