2

Does Database.getQueryLocator respect order by clause while running a batch? I am using following code

Database.getQueryLocator([select id,name from account order by industry asc])

Will this batch first process records where industry is null?

3

I believe the answer is yes it does, and yes it will.

This is the results from the query in Dev console:

enter image description here

Which I appreciate doesn't answer your question, but I know that Database.getQueryLocator does certainly appear to respect sort order from having used it in the past in other projects - e.g. for sorting Opportunity Line Items by AccountID and Quantity.

4

SOQL returns null values first per the salesforce documentation, unless you specify NULLS LATST in your query. To avoid confusion you can chose to expressly say NULLS FIRST if that is what you want.

Regardless of nulls first or nulls last they will be included unless they are expressly excluded by your WHERE clause.

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.