18.11.2008, 18:09 | #1 |
Участник
|
Вложенный датасорс с QueryRun
Есть такой код:
X++: static void Test_Query(Args _args) { CustTable custTable; AddressState addressState; Query query = new Query(); QueryRun qr = new queryRun(query); QueryBuildDataSource qbds = qr.query().addDataSource(tableNum(CustTable)); QueryBuildDataSource qbdsJoin; int i; ; qbds.addSelectionField(fieldnum(CustTable,RecId),SelectionField::Count); qbds.addSortField(fieldnum(CustTable,CashDisc)); qbds.addSortField(fieldnum(CustTable,CountryRegionId)); qbds.addSortField(fieldnum(CustTable,State)); qbds.orderMode(OrderMode::GroupBy); qbdsJoin = qbds.addDataSource(tablenum(AddressState)); qbdsJoin.relations(false); qbdsJoin.orderMode(OrderMode::OrderBy); qbdsJoin.joinMode(JoinMode::OuterJoin); qbdsJoin.addlink(fieldnum(CustTable,CountryRegionId),fieldnum(AddressState,CountryRegionId)); qbdsJoin.addlink(fieldnum(CustTable,State),fieldnum(AddressState,StateId)); qbdsJoin.addSelectionField(fieldnum(AddressState,Name)); if (qr.prompt()) { i=0; while (qr.next()) { custTable = qr.get(tableNum(CustTable)); addressState = /* ЧТО ЗДЕСЬ ДОЛЖНО БЫТЬ*/ print strfmt("%1 %2 (%3 records)",addressState.Name, custTable.CashDisc ,custTable.RecId); i+=custTable.RecId; } } pause; } X++: addressState = qr.get(tableNum(ddressState )); Или вообще релейшн неправильно построен? То тогда как верно это сделать? |
|
|
|