I want to see the result which Database.getQueryLocator(query) is returning in 'open execute anonymous window' so how to debug to see the result coming in that.

global database.querylocator start(Database.BatchableContext BC)
    return Database.getQueryLocator(query);

Just simply run this query in anonymous window and you will get the result. Check code sample below.

string query = 'Select id from account';
//add code to display the result.
Database.QueryLocator q = Database.getQueryLocator(s);
// Get an iterator
Database.QueryLocatorIterator it =  q.iterator();

// Iterate over the records
while (it.hasNext())
    Account a = (Account)it.next();

Replace query with your query string.

  • 2
    Good one.. I was bit confuse what should I reply to this question. :-)
    – Ratan Paul
    Feb 29 '16 at 6:53
  • Or we can can directly write: system.debug('Result of query----'+Database.query(query)); Feb 29 '16 at 9:23
  • @Vinod Yes we can. But OP is asking for Database.getQueryLocator(query) Feb 29 '16 at 10:04

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.