1 |
tony |
21 |
unit MainForm;
|
2 |
|
|
|
3 |
|
|
{$mode objfpc}{$H+}
|
4 |
|
|
|
5 |
|
|
interface
|
6 |
|
|
|
7 |
|
|
uses
|
8 |
|
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
9 |
|
|
ExtCtrls;
|
10 |
|
|
|
11 |
|
|
type
|
12 |
|
|
|
13 |
|
|
{ TForm1 }
|
14 |
|
|
|
15 |
|
|
TForm1 = class(TForm)
|
16 |
|
|
HavingAllUnions: TCheckBox;
|
17 |
|
|
Button1: TButton;
|
18 |
|
|
WhereAllUnions: TCheckBox;
|
19 |
|
|
WhereCondition: TEdit;
|
20 |
|
|
HavingCondition: TEdit;
|
21 |
|
|
HavingConditionType: TRadioGroup;
|
22 |
|
|
OrderBy: TEdit;
|
23 |
|
|
Label1: TLabel;
|
24 |
|
|
Label2: TLabel;
|
25 |
|
|
Label3: TLabel;
|
26 |
|
|
Label4: TLabel;
|
27 |
|
|
Label5: TLabel;
|
28 |
|
|
OriginalSQL: TMemo;
|
29 |
|
|
GeneratedSQL: TMemo;
|
30 |
|
|
WhereConditionType: TRadioGroup;
|
31 |
|
|
procedure Button1Click(Sender: TObject);
|
32 |
|
|
private
|
33 |
|
|
{ private declarations }
|
34 |
|
|
public
|
35 |
|
|
{ public declarations }
|
36 |
|
|
end;
|
37 |
|
|
|
38 |
|
|
var
|
39 |
|
|
Form1: TForm1;
|
40 |
|
|
|
41 |
|
|
implementation
|
42 |
|
|
|
43 |
|
|
{$R *.lfm}
|
44 |
|
|
|
45 |
|
|
uses IBSQLParser;
|
46 |
|
|
|
47 |
|
|
{ TForm1 }
|
48 |
|
|
|
49 |
|
|
procedure TForm1.Button1Click(Sender: TObject);
|
50 |
|
|
var Parser: TSelectSQLParser;
|
51 |
|
|
begin
|
52 |
|
|
Parser := TSelectSQLParser.Create(nil,OriginalSQL.Lines);
|
53 |
|
|
try
|
54 |
|
|
if WhereCondition.Text <> '' then
|
55 |
|
|
Parser.Add2WhereClause(WhereCondition.Text,WhereConditionType.ItemIndex <> 0,WhereAllUnions.Checked);
|
56 |
|
|
if HavingCondition.Text <> '' then
|
57 |
|
|
Parser.Add2HavingClause(HavingCondition.Text,HavingConditionType.ItemIndex <> 0,HavingAllUnions.Checked);
|
58 |
|
|
if OrderBy.Text <> ''then
|
59 |
|
|
Parser.OrderByClause := OrderBy.Text;
|
60 |
|
|
GeneratedSQL.Lines.Text := Parser.SQLText
|
61 |
|
|
finally
|
62 |
|
|
end;
|
63 |
|
|
end;
|
64 |
|
|
|
65 |
|
|
end.
|
66 |
|
|
|