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
penchala rajupenchala raju 

how to display the records fetching from batch apex start() method

global class batchupdate implements Database.Batchable<sobject>
{

    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator('select id,name,industry from account');
    }
    global void execute(Database.BatchableContext bc,list<account> scope)
    {
        list<account> cust=new List<account>();
        for(account c:scope)
        {
            c.name='mr'+c.name;
            cust.add(c);
        
        }
        update cust;
    }
        global void finish(Database.BatchableContext bc)
        {
           
            
        }
    
}

batch execution:

batchupdate bp=new batchupdate();
Database.executeBatch(bp,5);

here i divided 5 batches.i want to display these records in visual force
Amit Chaudhary 8Amit Chaudhary 8
You can try System.debug
global class batchupdate implements Database.Batchable<sobject>
{

    global Database.QueryLocator start(Database.BatchableContext bc)
    {
		String Query = 	'select id,name,industry from account';
		System.debug('------Query---->'+Query);
        return Database.getQueryLocator(Query);
    }
	
    global void execute(Database.BatchableContext bc,list<account> scope)
    {
        list<account> cust=new List<account>();
		System.debug('------scope---->'+scope.size());
        for(account c:scope)
        {
            c.name='mr'+c.name;
            cust.add(c);
        
        }
        update cust;
    }
	
	global void finish(Database.BatchableContext bc)
	{
	   
		
	}
	
}

 
penchala rajupenchala raju
how to display in vf page.i tried but not working.can any solve to write VF page using the above batch class
Amit Chaudhary 8Amit Chaudhary 8
Below blog will help you
http://www.tehnrd.com/batch-apex-status-bar/

Please let us know if this will help you.
penchala rajupenchala raju
can u write vf page for above program to display the records fetched from batch apex class
surasura
Hi raju ,

you cant user batch apex to fetch data for a visual force page as batch apex is executed asynchronously .could you eloborate your requirement .
 normaly batch apex is used to large dml operations within govenor limits.