Hi Friends,
I try to build a query to join multiple tables. But, get a strange problem. I run code to the line of 30 . But, in debug, I can see query like this, it's joined on different field.(AttributeGroup = Product), this is not right. But, where is the problem?
Many thanks,
SELECT * FROM WrkCtrTable(WrkCtrTable_1)
WHERE ((WrkCtrId = N'1101'))
JOIN * FROM SequencingGroupAttribute(SequencingGroupAttribute_1)
ON WrkCtrTable.SequencingAttributeGroup = SequencingGroupAttribute.AttributeGroup
JOIN * FROM SequencingProductAttributeValue(SequencingProductAttributeValue_1)
ON SequencingGroupAttribute.AttributeGroup = SequencingProductAttributeValue.Product
Here is code:
Query query = new Query();
QueryRun queryRun;
WrkCtrTable wrkCtrTable;
SequencingProductAttributeValue SequencingProductAttributeValue;
SequencingAttributeValue SequencingAttributeValue;
QueryBuildDataSource qbdsMachineAttributeGroup;
QueryBuildDataSource qbdsAttributeGroup;
QueryBuildDataSource qbdsGroupAttribute;
QueryBuildDataSource qbdsProducAttributes;
QueryBuildDataSource qbdsAttributeValues;
QueryBuildDataSource qbdsChangeOverMatrix;
QueryBuildRange qbrMachine;
QueryBuildRange qbrProduct;
;
qbdsMachineAttributeGroup = query.addDataSource(tableNum(WrkCtrTable));
qbrMachine = qbdsMachineAttributeGroup.addRange(fieldNum(WrkCtrTable, WrkCtrId));
//qbrMachine.value(queryValue(wrkCtrTable.WrkCtrId));
qbrMachine.value('1101');
qbdsGroupAttribute = qbdsMachineAttributeGroup.addDataSource(tableNum(SequencingGroupAttribute));
qbdsGroupAttribute.joinMode(JoinMode::InnerJoin);
qbdsGroupAttribute.addLink(fieldNum(SequencingGroupAttribute, AttributeGroup), fieldNum(WrkCtrTable, SequencingAttributeGroup));
qbdsProducAttributes = qbdsGroupAttribute.addDataSource(tableNum(SequencingProductAttributeValue));
qbdsProducAttributes.joinMode(JoinMode::InnerJoin);
qbdsProducAttributes.addLink(fieldNum(SequencingProductAttributeValue, Attribute), fieldNum(SequencingGroupAttribute, Attribute));
//qbrProduct = qbdsProducAttributes.addRange(fieldNum(SequencingProductAttributeValue, Product));
//qbrProduct.value(queryValue(SequencingProductAttributeValue.Product));
//qbrProduct.value('22565424963');
qbdsProducAttributes.joinMode(JoinMode::InnerJoin);
qbdsProducAttributes.addLink(fieldNum(SequencingProductAttributeValue, Attribute), fieldNum(SequencingGroupAttribute, Attribute));
qbdsAttributeValues = qbdsProducAttributes.addDataSource(tableNum(SequencingAttributeValue));
qbdsAttributeValues.relations(true);
queryRun = new queryRun(query);
while(queryRun.next())
{
SequencingAttributeValue = queryRun.get(tablenum(SequencingAttributeValue));
info(strfmt("%1",SequencingAttributeValue.Value));
*This post is locked for comments
I have the same question (0)