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
UsamaUsama 

need to processing over 200000 records

Hi Guys,
I have a button in a s-control where I am calling webservice apex code in which i am copying more then 200000 records from master object with its child object to an other master object with its child object.I am recieving an error "Too many scripts 200001" statements.
is there any way to do effieciently as my apex webservice method code is below.Please review it and let me know how can I efficiently process these no of records without reaching  script statements governor limits?
 
Thanks!
Usama
 

for (List <CampaignScheduler__c> OpportunityDailySchedulesDates : [select Id,Campaign__c,Date__c,CurrencyIsoCode,Opportunity__c,Status__c from CampaignScheduler__c where Opportunity__c =: OppId])

{

List <CampaignScheduler__c> ClonedDailySchedules = new CampaignScheduler__c[]{};

for (Integer i=0; i < OpportunityDailySchedulesDates.size(); i++)

{

String CampId = OpportunityDailySchedulesDates[i].Campaign__c;

CampaignScheduler__c ClonedCampaignDailyScheduleDates = new CampaignScheduler__c();

ClonedCampaignDailyScheduleDates.Campaign__c = getMappedID(ListofAllCampaigns,CampId);

ClonedCampaignDailyScheduleDates.Opportunity__c = newOppId;

ClonedCampaignDailyScheduleDates.Date__c = OpportunityDailySchedulesDates[i].Date__c;

ClonedCampaignDailyScheduleDates.Status__c = OpportunityDailySchedulesDates[i].Status__c;

ClonedCampaignDailyScheduleDates.CurrencyIsoCode = OpportunityDailySchedulesDates[i].CurrencyIsoCode;

ClonedDailySchedules.add(ClonedCampaignDailyScheduleDates);

}

insert ClonedDailySchedules;

}

}