1
我有一個使用Sales Table和Sales Line表作爲查詢數據源的查詢(感謝所有幫助過這個的人!)。在查詢運行部分,如果銷售訂單有多個銷售行附加到銷售行,我該如何循環銷售行結果?X ++ QueryBuilder嵌套結果
static void TestQuery(Args _args)
{
SalesTable salesTable;
SalesLine salesLine;
QueryBuildRange querybuildrange;
utcDateTime mutcDateTime;
date mDate;
QueryRun queryrun = new QueryRun(new Query());
QueryBuildDataSource datasourceA = queryrun.query().addDataSource(tableNum(SalesTable));
QueryBuildDataSource datasourceB = datasourceA.addDataSource(tableNum(SalesLine));
mDate = str2Date("25/09/2016", 123);
mutcDateTime = DateTimeUtil::newDateTime(mDate,0);
querybuildrange = datasourceA.addRange(FieldNum(SalesTable, CreatedDateTime));
querybuildrange.value(strFmt('>%1', mutcDateTime));
datasourceB.relations(true); // Link on SalesId
datasourceB.joinMode(JoinMode::ExistsJoin);
info(datasourceA.toString()); // This is the full query
while (queryrun.next())
{
salesTable = queryrun.get(tableNum(SalesTable));
salesLine = queryrun.get(tableNum(SalesLine));
info(salesTable.SalesId);
info(salesline.Name);
}
}
感謝Alex的回答,感謝幫助! –
不客氣。如果它是正確的,你可以標記答案正確... –