Last active
January 3, 2016 12:38
-
-
Save mtetlow/8463731 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Kick off with | |
Database.executeBatch(new batchUpdate(),50); | |
//Class like this | |
global class batchUpdate implements Database.Batchable<sObject> { | |
// This method returns a SOQL query locator containing the records | |
// to be iterated | |
global Database.QueryLocator start(Database.BatchableContext BC){ | |
return Database.getQueryLocator([SELECT Id,Something__c FROM CustomObj__c]); | |
} | |
// The executeBatch method is called for each chunk of records returned from start. | |
global void execute(Database.BatchableContext BC, List<CustomObj__c> scope){ | |
for(CustomObj__c obj : scope){ | |
obj.Something__c = 'wat'; | |
} | |
update scope; | |
} | |
global void finish(Database.BatchableContext BC){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment