Here is my start method of batch class at last line it is giving this error:

Method does not exist or incorrect signature: Database.getQueryLocater(String)

global Database.QueryLocator Start(Database.BatchableContext BC){

        String Query='SELECT Id,Name FROM Opportunity';
        return Database.getQueryLocater(Query);

Thanks In Advance

  • what are you trying to do? looks like you are trying to learn if yes check trailhead modules for learning developer.salesforce.com/trailhead/en/asynchronous_apex/…
    – Ratan Paul
    Aug 4 '16 at 6:07
  • I am trying to append a update word with opportunity name
    – Saurabh
    Aug 4 '16 at 6:08
  • 1
    @Saurabh Please edit the post and add the whole code.
    – Devendra
    Aug 4 '16 at 6:58
  • 1
    Have you written Database.getQueryLocater(String) above the method? please put up your full code here
    – Abhijeet
    Aug 4 '16 at 7:24
  • You mean you have a compile error not a method that is failing to return a value? As others suggests, cut and paste the entire class into your question; nothing appears wrong in the code you have posted.
    – Keith C
    Aug 4 '16 at 7:44

Spellcheck :) Database.getQueryLocator

Thanks KL


Best guess here is that you have your own class called Database (or database) or a field in your batchable class of that name that is shadowing (hiding) the system class. You can check that by adding the System namespace like this:

global System.Database.QueryLocator Start(System.Database.BatchableContext BC){
    String Query='SELECT Id,Name FROM Opportunity';
    return System.Database.getQueryLocater(Query);

If that fixes the problem, the best solution is to change that class or field name to avoid the problem so you don't have to keep adding the System namespace.

  • Keith -- overthinking this one :-) - OP misspelled method in code Database.getQueryLocater(String)
    – cropredy
    Aug 8 '16 at 15:32
  • @cropredy Occam's razor in action...
    – Keith C
    Aug 8 '16 at 15:54

Please try below code

global class batchaccount implements database.batchable{

global database.querylocator start(Database.batchablecontext bx){

    string query = 'SELECT Id,Name FROM Opportunity';
    return Database.getquerylocator(query);


global void execute(Database.batchablecontext bx,list<Opportunity> scope){

       //your code

global void finish(Database.batchablecontext bx){



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.