3

Every documentation on batch apex class shows the queryString variable declared as global. Is there a specific reason for doing so??

1 Answer 1

4

It does not need to be global or indeed there at all.

You can use compile-time checked static SOQL in the start method instead which is often a cleaner approach e.g.:

public Database.QueryLocator start(Database.BatchableContext bc) {
    return Database.getQueryLocator([select Name from Account]);
}

and the class and methods can be public instead of global.

You must log in to answer this question.

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