General X++ Development
What is the difference between `while select` and `QueryRun` in X++?
What is the difference between while select and QueryRun in X++?
1 answer
Write an answerUse while select when the query is known at compile time and the structure is straightforward.
Use QueryRun when you need to build or change the query dynamically.
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(CustTable));
QueryRun queryRun = new QueryRun(query);
while (queryRun.next())
{
CustTable custTable = queryRun.get(tableNum(CustTable));
}If the query is static, I normally keep it simple and use while select. If the user or runtime logic is changing datasources, ranges, or joins, QueryRun makes more sense.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer