I'm building a system where a user will be providing me with a query through a UI. This query will then be used in an Async Apex Job, by passing it as a param to Database.getQueryLocator
in the start
method.
Initially, I was using Database.query
or Database.countQuery
for validating a query and catching possible exceptions. But in actuality, there could be millions of records in which case these functions will throw an error saying I've exceeded governor limits.
Does Salesforce provide a way of compiling a query just to check whether it is valid? A quick Google search turns up nothing.