18.03.2010, 13:04 | #1 |
Участник
|
Помогите с query ...
Здраствыйте ,
Никак немогу добиться резултата в одном query . В ручную ето выглядит так и работает хорошо : Код: while select inventSum index hint LocateItemIdx where inventSum.InventLocationId == cInvLoc && inventSum.PhysicalInvent notexists join firstonly invTrn index hint ItemIdx where invTrn.ItemId == inventSum.ItemId && invTrn.inventDimId == inventSum.InventDimId && invTrn.DatePhysical >= dBgn Код: Query qInvSum2( Query qry ) { QueryBuildDataSource qBSSum; QueryBuildDataSource qBSTrn; ; qBSSum = qry.dataSourceTable( TableNum( InventSum ) ); qBSSum.addSortIndex( indexnum( InventSum, LocateItemIdx ) ); qBSSum.indexIsHint( true ); qBSSum.addRange( fieldNum( InventSum, PhysicalInvent ) ).value( queryvalue( '!= 0' ) ); qBSTrn = qBSSum.addDataSource( tableNum( InventTrans ) ); qBSTrn.addLink( fieldNum( InventTrans, InventDimId ), fieldNum( InventSum, InventDimId ) ); qBSTrn.addLink( fieldNum( InventTrans, ItemId ), fieldNum( InventSum, ItemId ) ); qBSTrn.addSortIndex( indexNum( InventTrans, DimIdIdx ) ); qBSTrn.indexIsHint( true ); qBSTrn.addRange( fieldNum( InventTrans, DatePhysical ) ).value( SysQuery::range( dBgn, dateMax() ) ); qBSTrn.joinMode( JoinMode::NoExistsJoin ); // qBSTrn.firstOnly( true ); //qBSTrn.fetchMode( QueryFetchMode::One2One ); return qry; } SELECT INDEXISHINT * FROM InventSum USING INDEX LocateItemIdx WHERE ((InventLocationId = LS)) AND ((ItemId = 1014c)) AND ((!PhysicalInvent= 0)) JOIN FIRSTONLY * FROM InventTable WHERE InventSum.ItemId = InventTable.ItemId AND ((ALNInventGroup1 = 200)) JOIN FIRSTONLY * FROM InventDim WHERE InventSum.InventDimId = InventDim.inventDimId EXISTS JOIN FIRSTONLY INDEXISHINT * FROM InventTrans USING INDEX DimIdIdx WHERE InventSum.InventDimId = InventTrans.inventDimId AND InventSum.ItemId = InventTrans.ItemId AND ((DatePhysical>=2010.02.01 AND DatePhysical<=2153.12.31)) Подчеркивал плохож место красным . Что я здесь плохо делаю ? Спасибо заранее за помощь ! С уважением , Римантас |
|