Navigation: ABC Library Reference > RelationManager > RelationManager Methods >====== AddRelationLink (set linking fields for a relationship) ====== | |
AddRelationLink( parentkey, childkey ), PROTECTED
AddRelationLink | Identifies the linking fields for a relationship between this object's primary file (see Me) and another file. |
parentkey | The label of the primary file's linking field. |
childkey | The label of the related file's linking field. |
The AddRelationLink method, in conjunction with the AddRelation method, describes a relationship between this object's primary file (see Me) and another file so that other RelationManager methods can cascade or constrain file operations across the related files when appropriate.
You must call AddRelationLink for each pair of linking fields, and the calls must be in sequence of high order linking fields to low order linking fields.
Implementation:
You should typically call AddRelationLink after the Init method is called (or within your derived Init method).
Example:
Orders FILE,DRIVER('TOPSPEED'),PRE(ORD),CREATE
ByCustomer KEY(ORD:CustNo,ORD:OrderNo),DUP,NOCASE,OPT
Record RECORD,PRE()
CustNo LONG
OrderNo LONG
OrderDate LONG
Reference STRING(24)
ShipTo STRING(32)
Shipped BYTE
Carrier STRING(1)
END
END
Items FILE,DRIVER('TOPSPEED'),PRE(ITEM),CREATE
AsEntered KEY(ITEM:CustNo,ITEM:OrderNo,ITEM:LineNo),NOCASE,OPT,PRIMARY
Record RECORD,PRE()
CustNo LONG
OrderNo LONG
LineNo SHORT
ProdCode SHORT
Quantity SHORT
END
END
CODE
!program code
Relate:Orders.Init PROCEDURE
CODE
SELF.AddRelation( Relate:Items,0,0, ITEM:AsEntered )
SELF.AddRelationLink( ORD:CustNo, ITEM:CustNo )
SELF.AddRelationLink( ORD:OrderNo, ITEM:OrderNo )
SELF.AddRelation( Relate:Customer )
See Also: AddRelation, Init