Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#109: How can I generate the script for SELECT-statement?

I know that you have a fan holiday (a Merry Christmas to all!) but I work today so serie of tips for SQL-script autogeneration is continue...

Today I want to publish a small procedure that generate a SELECT-statement for data of table. This code I uses in DIM: Database Information Manager:

function GetSelectTable(Dataset: TTable): TStrings;
var
  i: Integer;
  str: string;
begin
  Result := TStringList.Create;
  try
    for i := 0 to DataSet.FieldCount-1 do
    begin
      if i = 0 then
        str := 'SELECT'
      else
        str := ',';
      str := str + ' ' + DataSet.Fields[i].FieldName;
      Result.Add(str);
    end;
    Result.Add('FROM ' + DataSet.TableName)
  except
    Result.Free;
    Result := nil;
  end;
end;

Of course, you can add the ORDER BY-clause (just iterate by index fields) and/or GROUP BY-clause...


Published: December 25, 2000

See also
 
Paradox Password Recovery
DBISAM Password Recovery
Viewer for MS Outlook Messages
ABA Spreadsheet Convert
Clarion to Text converter
ExcelFile Viewer
SMMsg suite
Mail parser (ActiveX)
Fast Document Viewer
SMReport
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport/SMImport suites