function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
Please check the following data.
Sample CodeBatch Class :1: global class ExampleBatchClass implements Database.Batchable<sObject>{2:3: global ExampleBatchClass(){4: // Batch Constructor5: }6:7: // Start Method8: global Database.QueryLocator start(Database.BatchableContext BC){9: return Database.getQueryLocator(query);10: }11:12: // Execute Logic13: global void execute(Database.BatchableContext BC, List<sObject> scope){14: // Logic to be Executed batch wise15:16: }17:18: global void finish(Database.BatchableContext BC){19: // Logic to be Executed at finish20: }21: }
Call the Batch Class :
1: ExampleBatchClass b = new ExampleBatchClass();2: //Parameters of ExecuteBatch(context,BatchSize)3: database.executebatch(b,10);
Note : if batch size is not mentioned it is 200 by default.
That’s about it for this post, if you still want a deep dive into Batch Classes I suggest you read this
Do let me know your thoughts Happy Coding !
For more reference check the following link.
http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html
Thanks,
Subhani,
DBSync,
www.mydbsync.com
Hi
I have found out same post in developer's community.
Check the following link
http://boards.developerforce.com/t5/Apex-Code-Development/how-do-i-write-test-class-for-batch-apex-scheduler/td-p/507505
Thanks & Regards,
Do like this
In Test Class
YourObject obj = new YourObject();
insert obj;
List<YourObject> objList = new List<YourObject>();
RecordBatchApexClassName recBatchApex = new RecordBatchApexClassName();
objList.add(obj);recBatchApex.listAuditRecords .clear();Database.BatchableContext dbc;recBatchApex.start(dbc);recBatchApex.execute(dbc,objList);recBatchApex.finish(dbc);
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Hi,
Please check the following data.
Sample Code
Batch Class :
1: global class ExampleBatchClass implements Database.Batchable<sObject>{
2:
3: global ExampleBatchClass(){
4: // Batch Constructor
5: }
6:
7: // Start Method
8: global Database.QueryLocator start(Database.BatchableContext BC){
9: return Database.getQueryLocator(query);
10: }
11:
12: // Execute Logic
13: global void execute(Database.BatchableContext BC, List<sObject> scope){
14: // Logic to be Executed batch wise
15:
16: }
17:
18: global void finish(Database.BatchableContext BC){
19: // Logic to be Executed at finish
20: }
21: }
Call the Batch Class :
1: ExampleBatchClass b = new ExampleBatchClass();
2: //Parameters of ExecuteBatch(context,BatchSize)
3: database.executebatch(b,10);
Note : if batch size is not mentioned it is 200 by default.
That’s about it for this post, if you still want a deep dive into Batch Classes I suggest you read this
Do let me know your thoughts Happy Coding !
For more reference check the following link.
http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html
Thanks,
Subhani,
DBSync,
www.mydbsync.com
Hi
I have found out same post in developer's community.
Check the following link
http://boards.developerforce.com/t5/Apex-Code-Development/how-do-i-write-test-class-for-batch-apex-scheduler/td-p/507505
Thanks & Regards,
Subhani,
DBSync,
www.mydbsync.com
Do like this
In Test Class
YourObject obj = new YourObject();
insert obj;
List<YourObject> objList = new List<YourObject>();
RecordBatchApexClassName recBatchApex = new RecordBatchApexClassName();
objList.add(obj);
recBatchApex.listAuditRecords .clear();
Database.BatchableContext dbc;
recBatchApex.start(dbc);
recBatchApex.execute(dbc,objList);
recBatchApex.finish(dbc);
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks