static void Query(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource custDataSource,transDataSource;
QueryBuildRange qbr;
QueryBuildLink qbl;
CustTable custTable;
CustTrans custTrans;
;
q = new Query();
//Adding the parent DataSource
custDataSource = q.addDataSource(tablenum(CustTable));
//Adding the range
qbr = custDataSource.addRange(fieldnum(CustTable,AccountNum));
custDataSource.addSortField(fieldnum(CustTable,AccountNum));
transDataSource = custDataSource.addDataSource(tablenum(custTrans));
//Adding the Inner join for the two tables CustTable and CustTrans
transDataSource.joinMode(JoinMode::InnerJoin);
//Adding the relation for the two tables
//If the realtion doesn't exists
qbl =
transDataSource.addLink(fieldnum(CustTable,AccountNum),fieldnum(CustTrans,Accountnum));
//If the relation already exists for the two tables in the table level...
//Then we can use the following one...
transDataSource.relations(true);
qr = new QueryRun(q);
while(qr.next())
{
//Logic to print the data from query..
}
}
No comments:
Post a Comment