Previous Thread

8/16/2006 3:25:01 PM    InventTable join to InventItemGroup using query builder
Hey folks, 
 
I'm attempting to do the following query using the Query objects: 
 
SELECT * FROM inventTable EXISTS JOIN * FROM inventItemGroup 
 
WHERE inventTable.ItemGroupId == inventItemGroup.ItemGroupId 
 
&& ((inventItemGroup.myFlag == NoYes::Yes)) 
 
This X++ query runs and returns inventTable records that have 
 
inventItemGroup  rows with a custom myFlag set to Yes. 
 
i.e.  ItemGroup Stuff has myFlag set to yes, ItemGroup Junk has myFlag set 
 
to no.  Item A is a part of item group Stuff and Item B is a part of item 
 
group Junk.  When the InventTable form opens, I'd like only Item A to be 
 
returned. 
 
However, when I try using the Query objects, it doesn’t do the expected 
 
operation: 
 
form InventTable.init() 
 
Query                   q = new Query(); 
 
QueryBuildDataSource    qB,qBItemGroup; 
 
QueryBuildRange         qBr; 
 
; 
 
super(); 
 
qB = q.addDataSource(tableNum(InventTable)); 
 
qBItemGroup =qB.addDataSource(tableNum(InventItemGroup)); 
 
qBItemGroup.addLink(fieldNum(InventTable,ItemGroupId),fieldNum(InventItemGroup,ItemGroupId)); 
 
qBItemGroup.joinMode(JoinMode::ExistsJoin); 
 
qBr = qBItemGroup.addRange(fieldNum(InventItemGroup,myFlag)); 
 
qBr.value(enum2str(NoYes::Yes)); 
 
this.query(q); 
 
What happens is that rows are returned from inventTable, but they are 
 
tripled up and the range criteria for myFlag is being ignored. 
 
i.e. 
 
A 
 
A 
 
A 
 
B 
 
B 
 
B 
 
instead of just 
 
A 
 
Any ideas how implement such a query? 
 
Thanks!



8/17/2006 9:20:54 AM    Re: InventTable join to InventItemGroup using query builder
I can't see anything wrong with your code. I think you should try to find 
 
the cause somewhere else. 
 
Regards, 
 
Anton 
 
"pyll" <pyll@discussions.microsoft.com> wrote in message 
 
news:EE10253C-DCBF-4F10-ACD0-262FB966E68B@microsoft.com...