I have a table TableB
with a relation TableRel
to another table TableA
.
This relation is defined as TableA.FieldA == TableB.FieldB
I know how to get the relation's name with class method DictTable.relation()
:
DictTable dt;
dt = new DictTable(tableNum(MyTable));
info(strFmt("%1" , dt.relation(i)));
Is it possible to get and show the fields of the relation?
In my case I am looking to find TableA.FieldA == TableB.FieldB
. I don't know if a method exists to do this.
I assume you are trying to see the fields that make up the specified relation.
In order to do this, you use the DictRelation and DictField classes. Create a new DictRelation based on the table, and then use loadTableRelation() to specify the related table. Create new DictFields and use the DictRelation.lineExternTableValue() method to specify the specific fields:
DictRelation dr;
DictField Field;
DictField RelatedField;
int RelationIndex = 1;
dr = new DictRelation(tableNum(InventDim));
dr.loadTableRelation(tableNum(EcoResColor));
info(strFmt("%1", tableId2name(dr.externTable())));
Field = new DictField(tableNum(InventDim), dr.lineTableValue(RelationIndex));
RelatedField = new DictField(tableNum(EcoResColor), dr.lineExternTableValue(RelationIndex));
info(strFmt("%1 related to %2", Field.name(), RelatedField.name()));