Delphi Examples: DbiSortTable

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiSortTable

Return to chapter overview

Sort the source table into the destination table on the given field.

This example uses the following input:

 fDbiSortTable(CustomerTbl, CustomerTbl2, CustomerTbl.FieldByName('COMPANY'));

 

The function is:

function fDbiSortTable(SrcTbl, DestTbl: TTable; SortField: TField): Longint;

var

 Field: Word;

 CaseIns: Boolean;

 Recs: Longint;

begin

 Recs := SrcTbl.RecordCount;

 CaseIns := True;

 Field := SortField.Index + 1;

if not DestTbl.Active then

  raise EDatabaseError.Create('Cannot complete operation with ' +

    'destination table closed');

 Check(DbiSortTable(SrcTbl.DBHandle, nil, nil, SrcTbl.Handle, nil, nil,

   DestTbl.Handle, 1, @Field, @CaseIns, nil, nil, False, nil, Recs));

 Result := Recs;

end;