How to limit the records populated using query in X++

Hi Everyone,

Is there anyway to limit the record count to some specific values which is populated using query in X++ .

For Ex: if the query is populating 50 records means… how can we limit it to 10 or 15 records. In select statement we can use “Firstonly10” and get 10 values, likewise how to do in query. Please help me out…

Thanks in Advance…

I think there is no equivalent to firstonly10, only QueryBuildDataSource.firstOnly(). You’ll have to implement the limit on the application tier.

Hi Martin,

Thanks for the reply…

Can u explain little more about the line “implement the limit on the application tier” . How to do that?? any idea??

You’ll send a query without limit to database and stop processing records in X++ after the tenth or fifteenth record.

do you mean

query query = new query(queryStr(MyQuery));

queryrun qrun = new QueryRun(query);

counter i;

while (qrun.next())

{

i++;

if (i == 10)

break;

}

Yes, something like that.

Alonso, if your question’s been answered, please mark the verified solution.