How to write Dynamic query in x++
public static void main(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
q = new Query();
Sports sports; //tablename tablename reference
qbds=q.addDataSource(tableNum(Sports)); //addDataSource is used to add the table
qbds.addSortField(fieldNum(Sports,RunRate),SortOrder::Descending); // addSortField is used to sort the fields in asc or desc
qbr=qbds.addRange(fieldNum(Sports, RunRate)); //Addrange method is used to filter the records based on range
qbr.value(SysQuery::range('100','200'));
qr=new QueryRun(q); //Pass query to run it
while (qr.next())
{
sports=qr.get(tableNum(Sports));
info(strfmt("%1 - %2",Sports.Team,Sports.RunRate));
}
}
Comments
Post a Comment