Monday, August 27, 2018

How To Debug The Database.getQueryLocator(query)

If you Need to debug The Data in Database.getQueryLocator(query) use Bellow Sample Code to Debug the Data.
The Return Type Of The Database.getQueryLocator(query) is Database.QueryLocator.
Open Anonymous Window in Developer Console Copy and Paste Bellow Code.

Sample Code

String strQuery;
strQuery = 'Select Id.Name,Industry From Account limit 10';
Database.QueryLocator qu = Database.getQueryLocator(strQuery);
// Get an iterator
Database.QueryLocatorIterator it = qu.iterator();
// Iterate the records
while(it.hasNext()) {
    Account a = (Account)it.next();
    System.debug('====Account Values===='+a);
}

Result:
Let us Know If You Have any Queries.
Happy Learning !!!

1 comment: