I am trying to get a certain number of records at a time from AX. I want to perform something equivalent to:
SELECT * FROM (SELECT *, ROW_NUMBER() AS ROWNO
FROM TableName)
AS TableName WHERE ROWNO > startIndex
AND ROWNO <= endIndex;
Currently, I am fetching all records from AX (using .net business connector) :
axRecord.ExecuteStmt("select * from %1");
i = 0;
while(axRecord.Found)
{
if(i<startIndex)
{
i++;
continue;
}
// Perform operations
i++;
if(i==endIndex)
{
break;
}
}
Is there is a better way to do this using Business connector only? Kindly help
In the internal SQL syntax of X++ there is some keywords (
firstOnly, firstOnly10, firstOnly100, firstOnly1000) to limit how many rows will be fetched. It can be combined with RecId field to manually fetch groups of rows simulating pagination:You have complete syntax reference of select statement on MSDN:
http://msdn.microsoft.com/en-us/library/aa656402.aspx