3

I am using SOAP API to execute a SOQL. I need to get the size of my result

Does QueryResult.size() returns the actual size or the number of rows returned in the current execution

Consider I've a 45000 records and I want to get the count of the records. Executing a query will result in 500 records if I didn't modify the batch size.

So my question is, does QueryResult.size() will return me 45000 or 500? If it returns 500, is there any other way to get the count. I don't want to use select count() as the query is not constructed in my applicationm instead it is fed from some where.

Thanks in advance

1 Answer 1

4

According to the docs it's the number of records retrieved by the query, so I take that to mean 45,000 in your example:

Your client application can use this value to determine whether the query retrieved any rows (size > 0) or not (size = 0). Total number of rows retrieved in the query.

The QueryResult also includes a query locator which makes it easier to get the next group of records:

QueryLocator

In the QueryResult object returned by the query() call, queryLocator contains a value that you will use in the subsequent queryMore() call. Note the following guidelines:

  • Use a given queryLocator value only once. When you pass it in a queryMore() call, the API returns a new queryLocator in the QueryResult .
  • QueryLocator objects expire automatically after 15 minutes of inactivity.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .