Delphi Examples: DbiQGetBaseDescs

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiQGetBaseDescs

Return to chapter overview

Return the original database, table, and field names for a query.

The query from which the base descriptions come is specified in the Query parameter. Descriptions are added to the string list object specified in the List parameter. This example uses the following input:

 GetBaseDescs(Query2, Memo1.Lines);

 

procedure GetBaseDescs(Query: TQuery; List: TStrings);

var

 hCur: hDBICur;

 rslt: DBIResult;

 Descs: STMTBaseDesc;

begin

 hCur := nil;

try

   // Look at DbiQGetBaseDescs in the BDE32.HLP for more information...

   Check(DbiQGetBaseDescs(Query.STMTHandle, hCur));

  repeat

     rslt := DbiGetNextRecord(hCur, dbiNOLOCK, @Descs, nil);

    if (rslt = DBIERR_NONE) then

       // Look at STMTBaseDescs in the BDE32.HLP for more information...

       List.Add(Format('DB Name: %s  Table Name: %s  Field Name: %s',

         [Descs.szDatabase, Descs.szTableName, Descs.szFieldName]))

    else

      if (rslt <> DBIERR_EOF) then

         Check(rslt);

  until (rslt <> DBIERR_NONE);

finally

  if (hCur <> nil) then

     check(DbiCloseCursor(hCur));

end;

end;