+ Start a Discussion
yuliayulia 

Invalid type: Database.QueryLocator

Hi all,

i want to ask a question about this error --> Error: Compile Error: Invalid type: Database.QueryLocator at line 3 column 12. 

 

this is my apex class :

 

Global class Lat2_ApexBatch implements Database.Batchable<sObject>
{
    global Database.QueryLocator start (Database.BatchableContext BC)
    {
        return Database.getQueryLocator ('Select a.Id, a.name,a.NumberofLocations__c from Account a');
    }
    
    global void execute (Database.BatchableContext BC, List<account> scope)
    {
        List<Account> accInsert = new List<Account>();
        for (Account acc : scope)
        {
            acc.NumberofLocations__c = 0;
            accInsert.add (acc);
        }
        
        update accInsert;
    }
    
    global void finish (Database.BatchableContext BC)
    {
        
    }
}


any suggestion would be appreciated??

 

thx..

Yulia

 

 

sh-at-youseesh-at-yousee

Hi,

 

Seems strange. I just tried to copy/paste your code into Eclipse and all I had to do was to change NumberofLocations__c to a field that actually exists on our Account object.

 

After that small change, the code saved fine to the server - no compilation errors.

 

I did this using Eclipse (Force.com plugin) and API version was set to 18.

 

/Søren Nødskov Hansen

sravusravu

Hi,

     Even I have copy pasted the code as it is (I already have a custom field number of locations on my account object) in the UI and it worked fine for me. I did not get any error. My apex version setting was set to 20.0. Try the code once again and see (both UI and Eclipse).

Edwin KEdwin K

Hi,

 

I have the same problem, it shows the error "Error: Compile Error: Invalid type: Database.QueryLocator ..."

Is it because there are some features missing in my salesforce instance? My version is 20.0 but the error shows up with every "database." signature.

 

Any suggestions would be great.

Thanx

sh-at-youseesh-at-yousee

Hi,

 

It seems atrange if the Database methods are unavalable in your SF license. What license do you have with SF?

 

I've verified the code in Unlimited Edition and Developer Edition - both with success.

 

I'll try to investigate a bit more but maybe someone else can come up with an explanation?

 

/Søren Nødskov Hansen