+ Start a Discussion

Can't execute batch apex in Winter 10 sandbox.

Below is a very simple batch class but it is failing as soon as it starts to execute.

global class batchTest implements Database.Batchable<SObject>{

global database.querylocator start(Database.BatchableContext bc){
return Database.getQueryLocator('select Id, Name from Account where Name = \'batchTesting\'');

global void execute(Database.BatchableContext bc, sObject[] objects){
List<Account> accns = new List<Account>();
for(sObject s : objects){
Account a = (Account)s;
a.Description = 'batch testing. blah blah blah. ' + system.now();
update accns;

global void finish(Database.BatchableContext bc){
system.debug('all done.');

Here is the error:

Apex script unhandled exception by user/organization: 00550000000wOce/00DQ00000009Pxq Source organization: 00D00000000hXqv (null) Failed to process batch for class 'batchTest'

Debug Log:
20090930224059.163:External entry point: returning Database.QueryLocator from method global Database.QueryLocator start(Database.BatchableContext) in 0 ms
20090930224059.163:Class.batchTest.start: line 4, column 16: SOQL locator query with 10001 rows finished in 183 ms


Does anybody see anything glaringly wrong? I've basically copy and pasted this from the Developer Guide. One thing that seems wrong is that it says the query locator returns 10001 records, it should be 30,000.


I am trying to initiate this from the debug log with the following code:

batchTest job = new batchTest();
ID batchprocessid = Database.executeBatch(job);

I'm not sure if this makes a difference, but worth noting.




Message Edited by TehNrd on 10-01-2009 04:14 PM
So it appears query limits are being enforce when using the query locator.

If you limit the query to 10,000 rows it works fine. Anything higher than that and it fails.
Ron WildRon Wild

The code looks right, and the docs say you should be able to process up to 50 million records.


Maybe it's a sandbox limitation ... or a bug.

Currently escalated to Tier 3 support. I'm guessing bug.
It was a bug, fixed now.


I've been looking for information about Apex Batch, how to write them, execute them and I found this post.

In order to understand better how can I use them, I've copied your batch. I've added the global class batchTest, change the Name account like one of min, and run into the debug log the batch. I didn't get any errors, but it didn't change my contact description.

Could anyone help me?

Thanks, Majo