Sunday, December 21, 2008

How to count records in a Query

Query q;
QueryRun qr;
QueryBuildDataSource qbd;
;
q = new Query();
qbd = q.addDataSource(TableNum(CustTable));
qr = new QueryRun(q);
info(int2str(SysQuery::countTotal(qr)));
As seen you can use SysQuery object.
Runtime / Performance considerations
The call you are doing here works well if and only if you have exactly one datasource in the query. In the case you are starting to join up stuff here, things get complicated, as the implementation behind this call (specifically SysQuery::countPrim()) does actually loop over the entire resultset. It has to be taken with care therefore.
Retrieved from "http://www.axaptapedia.com/How_to_count_records_in_a_Query"

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...