Delphi Examples: DbiOpenFieldList

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiOpenFieldList

Return to chapter overview

Display logical or physical field types for a table

This example uses the following input:

 fDbiOpenFieldList(Table1, True, Memo1.Lines);

 

The procedure is:

procedure fDbiOpenFieldList(Table: TTable; Physical: Boolean; List: TStrings);

 

function BDEFieldIntToStr(FieldType: Word): string;

begin

case FieldType of

   fldUNKNOWN: result := 'unknown';

   fldZSTRING: result := 'string';               { Null terminated string }

   fldDATE: result := 'date';                    { Date     (32 bit) }

   fldBLOB: result := 'BLOb';                    { Blob }

   fldBOOL: result := 'boolean';                 { Boolean  (16 bit) }

   fldINT16: result := 'integer';                { 16 bit signed number }

   fldINT32: result := 'long integer';           { 32 bit signed number }

   fldFLOAT: result := 'float';                  { 64 bit floating point }

   fldBCD: result := 'BCD';                      { BCD }

   fldBYTES: result := 'bytes';                  { Fixed number of bytes }

   fldTIME: result := 'time';                    { Time        (32 bit) }

   fldTIMESTAMP: result := 'timestamp';          { Time-stamp  (64 bit) }

   fldUINT16: result := 'unsigned int';          { Unsigned 16 bit integer }

   fldUINT32: result := 'unsigned long int';     { Unsigned 32 bit integer }

   fldFLOATIEEE: result := 'float IEEE';         { 80-bit IEEE float }

   fldVARBYTES: result := 'varbytes';            { Length prefixed var bytes }

   fldLOCKINFO: result := 'lockinfo';            { Look for LOCKINFO typedef }

   fldCURSOR: result := 'Oracle cursor';         { For Oracle Cursor type }

 

   { Paradox types (Physical) }

   fldPDXCHAR: result := 'alpha';                { Alpha    (string) }

   fldPDXNUM: result := 'numeric';               { Numeric }

   fldPDXMONEY: result := 'money';               { Money }

   fldPDXDATE: result := 'date';                 { Date }

   fldPDXSHORT: result := 'smallint';            { Short }

   fldPDXMEMO: result := 'Memo BLOb';            { Text Memo       (blob) }

   fldPDXBINARYBLOB: result := 'Binary BLOb';    { Binary data     (blob) }

   fldPDXFMTMEMO: result := 'formatted BLOb';    { Formatted text  (blob) }

   fldPDXOLEBLOB: result := 'OLE BLOb';          { OLE object      (blob) }

   fldPDXGRAPHIC: result := 'Graphic BLOb';      { Graphics object (blob) }

   fldPDXLONG: result := 'long integer';         { Long }

   fldPDXTIME: result := 'time';                 { Time }

   fldPDXDATETIME: result := 'date time';        { Time Stamp }

   fldPDXBOOL: result := 'boolean';              { Logical }

   fldPDXAUTOINC: result := 'auto increment';    { Auto increment (long) }

   fldPDXBYTES: result := 'bytes';               { Fixed number of bytes }

   fldPDXBCD: result := 'BCD';                   { BCD (32 digits) }

 

   { xBASE types (Physical) }

   fldDBCHAR: result := 'character';             { Char string }

   fldDBNUM: result := 'number';                 { Number }

   fldDBMEMO: result := 'Memo BLOb';             { Memo          (blob) }

   fldDBBOOL: result := 'logical';               { Logical }

   fldDBDATE: result := 'date';                  { Date }

   fldDBFLOAT: result := 'float';                { Float }

   fldDBLOCK: result := 'LOCKINFO';              { Logical type is LOCKINFO }

   fldDBOLEBLOB: result := 'OLE BLOb';           { OLE object    (blob) }

   fldDBBINARY: result := 'Binary BLOb';         { Binary data   (blob) }

   fldDBBYTES: result := 'bytes';                { Only for TEMPORARY tables }

   fldDBLONG: result := 'long integer';          { Long (Integer) }

   fldDBDATETIME: result := 'date time';         { Time Stamp }

   fldDBDOUBLE: result := 'double';              { Double }

   fldDBAUTOINC: result := 'auto increment';      { Auto increment (long) }

else

   Result := 'not found';

end;

end;

 

var

 hFieldCur: hDBICur;

 rslt: DBIResult;

 Field: FLDDesc;

begin

 List.Clear;

 Check(DbiOpenFieldList(Table.DBHandle, PChar(Table.TableName), nil,

   Physical, hFieldCur));

repeat

   rslt := DbiGetNextRecord(hFieldCur, dbiNOLOCK, @Field, nil);

  if (rslt = DBIERR_NONE) then begin

     List.Add(Format('Field #%d) Name:%s Type:%s', [Field.iFldNum,

       Field.szName, BDEFieldIntToStr(Field.iFldType)]));

  end;

until (rslt <> DBIERR_NONE);

end;