27 |
|
|
28 |
|
{$Mode Delphi} |
29 |
|
|
30 |
+ |
{$codepage UTF8} |
31 |
+ |
|
32 |
|
interface |
33 |
|
|
34 |
|
uses Classes, DB; |
117 |
|
FCTE: TCTEDef; |
118 |
|
FNested: integer; |
119 |
|
FDestroying: boolean; |
120 |
+ |
FOwner: TSelectSQLParser; |
121 |
|
procedure AddToSQL(const Word: string); |
122 |
|
procedure CTEClear; |
123 |
|
function GetCTE(Index: integer): PCTEDef; |
137 |
|
procedure SetGroupClause(const Value: string); |
138 |
|
procedure SetFromClause(const Value: string); |
139 |
|
protected |
140 |
< |
constructor Create(SQLText: TStrings; StartLine, StartIndex: integer); overload; |
140 |
> |
constructor Create(aOwner: TSelectSQLParser; SQLText: TStrings; StartLine, StartIndex: integer); overload; |
141 |
|
procedure Changed; |
142 |
|
public |
143 |
|
constructor Create(aDataSet: TDataSet; SQLText: TStrings); overload; |
178 |
|
uses Sysutils, IBCustomDataSet; |
179 |
|
|
180 |
|
resourcestring |
178 |
– |
sNoEndToThis = 'Unterminated string'; |
181 |
|
sBadBy = 'Unexpected symbol "BY" in: %s'; |
182 |
|
sBadSymbol = 'Unknown Symbol'; |
183 |
|
sIncomplete = 'Incomplete Union'; |
582 |
|
begin |
583 |
|
if FIndex > length(Lines[I]) then |
584 |
|
if I+1 < Lines.Count then |
585 |
< |
FUnion := TSelectSQLParser.Create(Lines,I+1,1) |
585 |
> |
FUnion := TSelectSQLParser.Create(self,Lines,I+1,1) |
586 |
|
else |
587 |
|
raise Exception.Create(sIncomplete) |
588 |
|
else |
589 |
< |
FUnion := TSelectSQLParser.Create(Lines,I,FIndex); |
589 |
> |
FUnion := TSelectSQLParser.Create(self,Lines,I,FIndex); |
590 |
|
Exit |
591 |
|
end; |
592 |
|
end; |
668 |
|
constructor TSelectSQLParser.Create(aDataSet: TDataSet; SQLText: TStrings); |
669 |
|
begin |
670 |
|
FDataSet := aDataSet; |
671 |
< |
Create(SQLText,0,1) |
671 |
> |
Create(nil,SQLText,0,1) |
672 |
|
end; |
673 |
|
|
674 |
|
constructor TSelectSQLParser.Create(aDataSet: TDataSet; const SQLText: string); |
683 |
|
end |
684 |
|
end; |
685 |
|
|
686 |
< |
constructor TSelectSQLParser.Create(SQLText: TStrings; StartLine, |
687 |
< |
StartIndex: integer); |
686 |
> |
constructor TSelectSQLParser.Create(aOwner: TSelectSQLParser; |
687 |
> |
SQLText: TStrings; StartLine, StartIndex: integer); |
688 |
|
begin |
689 |
|
inherited Create; |
690 |
+ |
FOwner := aOwner; |
691 |
|
FParamList := TStringList.Create; |
692 |
|
FCTEs := TList.Create; |
693 |
|
FLastSymbol := sqNone; |
700 |
|
|
701 |
|
procedure TSelectSQLParser.Changed; |
702 |
|
begin |
703 |
+ |
if FOwner <> nil then |
704 |
+ |
FOwner.Changed |
705 |
+ |
else |
706 |
|
if assigned(FOnSQLChanging) and not FDestroying then |
707 |
|
OnSQLChanging(self) |
708 |
|
end; |
873 |
|
|
874 |
|
procedure TSelectSQLParser.SetSelectClause(const Value: string); |
875 |
|
begin |
876 |
< |
if Union <> nil then Union.SelectClause := Value; |
877 |
< |
FSelectClause := Value; |
878 |
< |
Changed |
876 |
> |
if FSelectClause <> Value then |
877 |
> |
begin |
878 |
> |
FSelectClause := Value; |
879 |
> |
Changed |
880 |
> |
end; |
881 |
|
end; |
882 |
|
|
883 |
|
procedure TSelectSQLParser.SetFromClause(const Value: string); |
884 |
|
begin |
885 |
< |
if Union <> nil then |
886 |
< |
Union.FromClause := Value |
887 |
< |
else |
888 |
< |
FFromClause := Value; |
889 |
< |
Changed |
885 |
> |
if FFromClause <> Value then |
886 |
> |
begin |
887 |
> |
FFromClause := Value; |
888 |
> |
Changed |
889 |
> |
end; |
890 |
|
end; |
891 |
|
|
892 |
|
procedure TSelectSQLParser.SetGroupClause(const Value: string); |
893 |
|
begin |
894 |
< |
if Union <> nil then |
895 |
< |
Union.GroupClause := Value |
896 |
< |
else |
897 |
< |
FGroupClause := Value; |
898 |
< |
Changed |
894 |
> |
if FGroupClause <> Value then |
895 |
> |
begin |
896 |
> |
FGroupClause := Value; |
897 |
> |
Changed |
898 |
> |
end; |
899 |
|
end; |
900 |
|
|
901 |
|
procedure TSelectSQLParser.SetOrderByClause(const Value: string); |
903 |
|
if Union <> nil then |
904 |
|
Union.OrderByClause := Value |
905 |
|
else |
906 |
+ |
if FOrderByClause <> Value then |
907 |
+ |
begin |
908 |
|
FOrderByClause := Value; |
909 |
< |
Changed |
909 |
> |
Changed |
910 |
> |
end; |
911 |
|
end; |
912 |
|
|
913 |
|
procedure TSelectSQLParser.DropUnion; |