I have the following apex batch class:

global class BatchUpdateListItem implements Database.Batchable<sObject>, Database.AllowsCallouts {
    global List<UpdateProduct> update_product {get;set;}

    global Database.QueryLocator start(Database.BatchableContext BC){
        Set<String> field_names = new Set<String>();
        for (UpdateProduct o : update_product){
            for (attribute__c x : o.attributes){

        String query = 'SELECT ' + String.join(field_names, ',') + ' FROM Product__c';
        return Database.getQueryLocator(query);

    global void execute(Database.BatchableContext bc, List<Product__c> scope){


    global void finish(Database.BatchableContext bc){


I am getting the following syntax error on the line where the query string is initiated (line 12):

Save error: Argument must implement Iterable BatchUpdateListItem.cls

I do not see this simple problem's solution, I do not want to have an iterable batch, yet a query locator one. I do not see where it implements iterable, and therefore I do not understand where this error arises.

Any pointers would be appreciated.

1 Answer 1


String.join(...) expects an object which inherits the iterable interface as a first parameter, generally a list. Set does not implement the iterable interface, and as a result, you get this error message.

If you convert it over to a list before you call the string method, you'll be able to use your code as is.

String s = String.join(new List<String>(field_names), ',');

You can vote on an idea to change the set iterator behavior on the IdeaExchange.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .