You need to sign in to do that
Don't have an account?

create apex class to insert account object record to big object
global class bigObject implements database.Batchable<Sobject> {
global database.QueryLocator start(database.BatchableContext bc){
string query = 'select id,name,Industry from Account';
return database.getQueryLocator(query);
}
global void execute(database.BatchableContext bc , list<account> scope ){
list<Customer_Interaction__b> customer = new list<Customer_Interaction__b>();
for(account a : scope){
Customer_Interaction__b cusint = new Customer_Interaction__b();
a.Id=cusint.Id;
a.Name=cusint.Level_Achieved__c;
a.Industry=cusint.Game_Platform__c;
customer.add(cusint);
}
insert customer;
}
global void finish(database.BatchableContext bc){
}
}
global database.QueryLocator start(database.BatchableContext bc){
string query = 'select id,name,Industry from Account';
return database.getQueryLocator(query);
}
global void execute(database.BatchableContext bc , list<account> scope ){
list<Customer_Interaction__b> customer = new list<Customer_Interaction__b>();
for(account a : scope){
Customer_Interaction__b cusint = new Customer_Interaction__b();
a.Id=cusint.Id;
a.Name=cusint.Level_Achieved__c;
a.Industry=cusint.Game_Platform__c;
customer.add(cusint);
}
insert customer;
}
global void finish(database.BatchableContext bc){
}
}
The QueryLocator approach is not supported for any Virtual Entities that don't return a total size count. This is because BatchApex needs to know the total number of records to create the correct number of jobs.
Instead, use an Iterator with the batch
I thinks you no need to go to iterator type BC if you are querying the data from big object then you have to choose that approach.
You made some small mistakes in the batch class please change those and try that:
global class bigObject implements database.Batchable<Sobject> {
global database.QueryLocator start(database.BatchableContext bc){
string query = 'select id,name,Industry from Account';
return database.getQueryLocator(query);
}
global void execute(database.BatchableContext bc , list<account> scope ){
list<Customer_Interaction__b> customer = new list<Customer_Interaction__b>();
for(account a : scope){
Customer_Interaction__b cusint = new Customer_Interaction__b();
cusint.Id__c = a.Id; //create the custom field to store the Account Id.
cusint.Level_Achieved__c = a.Name;
cusint.Game_Platform__c = a.Industry;
customer.add(cusint);
}
insert customer; // or try database.insertImmediate(cusint);
}
global void finish(database.BatchableContext bc){
}
}
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj.
when i tried this code its giving mi following error
First error: Invalid id value for this SObject type: 0017F00000M5TxmQAF
When i replace cusint.Id=a.Id; with cusint.Account__c = a.Id; the error is gone and the batch gets executed successfully however when i query big object its not refelecting any data there.
Can you please let me know if anything else needs to be done
Thank
//cusint.Id=a.Id;
this is not working. am i doing something wrong.
Thanks