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
Paras JainParas Jain 

Sometime Execute sucessful , n some time got error, Please help

//First error: SQLException [common.exception.SfdcSqlException: ORA-01013: user requested cancel of current operation
//select /*ApexBatch.Class.DeleteFlatRecords.start: line 13*/ *
from (select "Id"
from (select t.deleted "IsDeleted_gen_1",
t.custom_ent...
global class DeleteFlatRecords implements Database.Batchable<sObject>
{
     
     
     
     // Start Method
     global Database.QueryLocator start(Database.BatchableContext BC)
     {
     String   Query='select id from flat__C ';
         return Database.getQueryLocator(query);
 
     }

    // Execute Logic
    global void execute(Database.BatchableContext BC, List<sObject>scope)
    {
       
        List<Flat__c> flatRecords=new List<Flat__C>();
        for(sObject s: scope)
        {
            flat__C f= (flat__C )s;
            flatRecords.add(f);
        }
        
        if(flatRecords.size()>0)
        delete flatRecords;      
   
    }
   
   
   
    global void finish(Database.BatchableContext BC)
    {
    
      FlatRecords b = new FlatRecords ();
      database.executebatch(b,500);
     // system.abortJob(sc.getTriggerId());
}}
Akshay DeshmukhAkshay Deshmukh
Hi,
I think you are getting time out exception.
If batch job takes to much time, it sometimes gives timeout exception. try with batch size 200.
If you are not getting timeout exception, then please post exception to be able to help you.
Hope it helpes.

Thanks