function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dke01dke01 

Dynamic Count()

How do I do this:

 

Integer totalRows = (Database.query(myQuery ))

 

 Now I get a error cannot convert sObject to Integer

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Database.query returns a list of sobjects.

 

Sounds like you should be using Database.countQuery. 

All Answers

bob_buzzardbob_buzzard

Database.query returns a list of sobjects.

 

Sounds like you should be using Database.countQuery. 

This was selected as the best answer
dke01dke01
Perfect thank you, not sure why I did not see that in the API