Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to generate a SELECT-statement in run-time Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Generate the SELECT-statement in run-time 08-Jun-03
Category
Database-SQL
Language
Delphi 2.x
Views
220
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik 

Generate the script for SELECT-statement

Answer:

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 
(http://www.scalabium.com/download/dbinfo.ziphttp://www.scalabium.com/download/dbinf
o.zip): 

1   function GetSelectTable(Dataset: TTable): TStrings;
2   var
3     i: Integer;
4     str: string;
5   begin
6     Result := TStringList.Create;
7     try
8       for i := 0 to DataSet.FieldCount - 1 do
9       begin
10        if i = 0 then
11          str := 'SELECT'
12        else
13          str := ',';
14        str := str + ' ' + DataSet.Fields[i].FieldName;
15        Result.Add(str);
16      end;
17      Result.Add('FROM ' + DataSet.TableName)
18    except
19      Result.Free;
20      Result := nil;
21    end;
22  end;


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

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC