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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Import bulk csv

Hello, 

I am importing large sets of Data using Batch Apex from visualForce page. I have collected the list value from Class and calling batch apex just to do DML. 

Below is my code, 

Calling from class : 
SPL_BatchImportGild splTar = new SPL_BatchImportGild(FinalTarList);
Database.executeBatch(splTar);

Batch:

global class SPL_BatchImportGild implements Database.Batchable<SObject> , Database.Stateful 
{
global SObject[] queue; // = new list<Cycle_Plan_Target_vod__c>();
    
    global SPL_BatchImportGild(SObject[] recs)
    {
        queue=recs;
    }
    
    public static SObject[] start(Database.BatchableContext context) {
    {
        // need to pass the Queue value to execute. But showing error message 'Variable does not exist: queue'.
    }
    
    global static void execute(Database.BatchableContext context, SObject[] records) {
        insert records;
    }
    gloBal void finish(Database.BatchableContext context) 
    {
        
    }

What could be the reason for this.? 

Thanks 

Vignesh

Best Answer chosen by Vigneshwaran Loganathan
Mouhamed N'DIONGUEMouhamed N'DIONGUE
Hello Vignesh,
Your problem here is that you're trying to access queue value with the start method being "STATIC". This cannot be done like this. So just delete the static key unless you really need this, and in this case you have to provide the queue as argument to the start. But as far as I see, you don't need the static key.

Regards
Mouhamed

All Answers

Mouhamed N'DIONGUEMouhamed N'DIONGUE
Hello Vignesh,
Your problem here is that you're trying to access queue value with the start method being "STATIC". This cannot be done like this. So just delete the static key unless you really need this, and in this case you have to provide the queue as argument to the start. But as far as I see, you don't need the static key.

Regards
Mouhamed
This was selected as the best answer
Vigneshwaran LoganathanVigneshwaran Loganathan
Hi Mohamad, yes i figured that later and forgot to update here :) Thanks for your quick response.!!