Query.Count - what does it stand for?

Query.Count - what does it stand for?


Accordingly to the "What's New in Version 4.2" document, there is a new output parameter in queries: "To improve control over queries results, a query count feature was added to both simple and advanced queries.".

What I'd like to know is what does this parameter return when using a:
- select statement? Does it return the number of all records that match my search criteria, even though I'm only fetching the first 10 (Max. Records = 10) to show on screen?
- update/delete statements (advanced queries only)? Does it return the number of affected rows?

Best regards,
Hi Fernando,

In Simple Queries, the Query.Count will return the number of records in the database that respect your query, independently of the Max. Records you defined. Semantically, is as if you performed a "Select Count(*)" over the original query without limits on the number of returned records, e.g., without "Top" or Max. Records.

The Query.List.Length will have the actual number of records fetched from the database which can be any number up to Max. Records (since there may be less records in the database than the Max. Records you defined).

In Advanced Queries is exactly the same, with the exception of queries that alter data in the database, such as "Delete" or "Update", to name a few. In these cases, you cannot use the Query.Count and, if you do access Query.Count in some expression, you'll get an error during Compilation.

Hope this clarifies,

Rodrigo Castelo
Hi Rodrigo,

Thanks for your help. Could the "number of affected rows" support be included as a feature request in Advanced Queries that use update or delete statements?

Best regards,
Hi Fernando,

Maybe you already know this trick, but it's already possible to receive the number of affected rows.

Just add a parameter of type Text to your query, e.g. 'strRowCount'. Set it to 'Expand Inline' and give it the value "@@ROWCOUNT".
In your query you add the line 'SELECT @StrRowCount' after your DELETE or UPDATE statement and you receive the number of rows affected. Of course you have to set the Output Structure to Integer for this.
Hi Fernando,

Absolutely. We will include this request in our pipeline for analysis and future delivery.


Thank you both!

Is this implemented in the last verions?
Hi João,

Unfortunatelly so far (version 8), the Advanced Queries do not return the number of affected rows, when performing an Update or Delete over an entity.