function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
G!R!G!R! 

Reg: Batch Apex

Hi ALL SFDC Experts,

 

I am new bee to  Batch Apex.No doc explains clearly these ...can any one  explain me

 

we have '  Execute()' Method:

 

what is the difference between these two methods and what does the highlighted ones are

 

global void execute(Database.Batchablecontext BC, List<sObject> Scope);

 

global void execute(Database.Batchablecontext BC, List<P>);

 


As I know 'BC' holds reference to the  'Batchablecontext ' object. But what are List<sObject> Scope and List<P>

 

In interview


 I have been asked which data type I use in execute method-- kept blank face?

 

And  what is the difference between sObject and object?

 

 

 

Thanks in Advance

Best Answer chosen by Admin (Salesforce Developers) 
ForceMantis (Amit Jain)ForceMantis (Amit Jain)

For deep knowledge of Batch Apex refere salesforce Apex Code developer guide. There is complete chaper on Batch Apex only.

 

http://www.salesforce.com/us/developer/docs/apexcode/index.htm

 

When we use batch apex salesforce Batch Runtime system call execute method multiple time passing 200 records(can be reduced if needed to up to 1) from all the records that Database.getQueryLocator instance return from Batch Start method. This is stored in List<sObject> scope.

 

List<P> is used if we don't select records from Database and implement our custom Iterator class.

 

sObject is a generic data type that can hold instace of any Native or custom object. While Object is a data type that can hold any data type value e.g. Primitive, classes created by you are provided by salesforce.