Delphi Examples: DbiBeginLinkMode

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiBeginLinkMode

Return to chapter overview

Create a master/detail link between two tables. The two hDBICur cusrors return linked handles to both tables. Tables must be open on the indexes to link on. This example only supports a 'full index' link; if the link is on a composite index, both tables must link on the complete index. This example uses the following input:

 fDbiBeginLinkMode(CustomerTbl, OrdersTbl, hMas, hDet);

 

The procedure is defined as:

procedure fDbiBeginLinkMode(MasTbl, DetTbl: TTable; var hMasCur,

hDetCur: hDBICur);

var

 MasIdxDesc, DetIdxDesc: IDXDesc;

begin

 Check(DbiCloneCursor(MasTbl.Handle, False, False, hMasCur));

 Check(DbiCloneCursor(DetTbl.Handle, False, False, hDetCur));

 Check(DbiGetIndexDesc(hMasCur, 0, MasIdxDesc));

 Check(DbiGetIndexDesc(hDetCur, 0, DetIdxDesc));

 Check(DbiSetToBegin(hMasCur));

 Check(DbiBeginLinkMode(hMasCur));

 Check(DbiBeginLinkMode(hDetCur));

 Check(DbiLinkDetail(hMasCur, hDetCur, MasIdxDesc.iFldsInKey,

   @MasIdxDesc.aiKeyFld, @DetIdxDesc.aiKeyFld));

end;