|
@@ -180,7 +180,6 @@ type
|
|
|
fmeResult: TMemo;
|
|
|
fSQLQuery: TSQLQuery;
|
|
|
fSQLScript: TSQLScript;
|
|
|
- // Text for caption
|
|
|
faText: string;
|
|
|
fModifyCount: Integer;
|
|
|
fCnt: Integer;
|
|
@@ -209,7 +208,6 @@ type
|
|
|
OnCommit: TNotifyEvent;
|
|
|
procedure Init(dbIndex: Integer);
|
|
|
function GetQueryType(AQuery: string): TQueryTypes;
|
|
|
- // Get query text from GUI/memo
|
|
|
function GetQuery: string;
|
|
|
// Takes existing query or script and uses it to create result tab
|
|
|
function CreateResultTab(QueryType: TQueryTypes; var aSqlQuery: TSQLQuery; var aSQLScript: TSqlScript;
|
|
@@ -313,17 +311,15 @@ var
|
|
|
i: Integer;
|
|
|
begin
|
|
|
for i:= QueryList.Count - 1 downto 0 do
|
|
|
+ if Pos('--', QueryList[i]) > 0 then
|
|
|
begin
|
|
|
- if Pos('--', QueryList[i]) > 0 then
|
|
|
- begin
|
|
|
- if Pos('--', Trim(QueryList[i])) = 1 then
|
|
|
- QueryList.Delete(i);
|
|
|
- {
|
|
|
- else
|
|
|
- //todo: this will also pick up -- within string literals which is wrong
|
|
|
- QueryList[i]:= Copy(QueryList[i], 1, Pos('--', QueryList[i]) - 1);
|
|
|
- }
|
|
|
- end;
|
|
|
+ if Pos('--', Trim(QueryList[i])) = 1 then
|
|
|
+ QueryList.Delete(i);
|
|
|
+ {
|
|
|
+ else
|
|
|
+ //todo: this will also pick up -- within string literals which is wrong
|
|
|
+ QueryList[i]:= Copy(QueryList[i], 1, Pos('--', QueryList[i]) - 1);
|
|
|
+ }
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -929,7 +925,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-{ Run current SQL, auto-detect type }
|
|
|
+{ Run current SQL, 0 for auto-detect type }
|
|
|
procedure TfmQueryWindow.tbRunClick(Sender: TObject);
|
|
|
begin
|
|
|
CallExecuteQuery(qtUnknown);
|
|
@@ -1045,9 +1041,9 @@ end;
|
|
|
|
|
|
function TfmQueryWindow.GetQuery: string;
|
|
|
begin
|
|
|
- Result:= trim(meQuery.SelText);
|
|
|
+ Result:= meQuery.SelText;
|
|
|
if Result = '' then
|
|
|
- Result:= trim(meQuery.Lines.Text);
|
|
|
+ Result:= meQuery.Lines.Text;
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -1336,6 +1332,7 @@ begin
|
|
|
fmeResult.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DML Executed. Takes (H:M:S.MS) ' +
|
|
|
FormatDateTime('HH:nn:ss.z', Now - StartTime));
|
|
|
fmeResult.Lines.Add('Rows affected: ' + Format('%3.0n', [Affected / 1]));
|
|
|
+
|
|
|
end;
|
|
|
fmeResult.Lines.Add('----');
|
|
|
fmeResult.Lines.Add(fQueryPart);
|
|
@@ -1696,7 +1693,7 @@ procedure TfmQueryWindow.FormClose(Sender: TObject;
|
|
|
begin
|
|
|
RemoveControls;
|
|
|
|
|
|
- // Check if the transaction is active; then commit it
|
|
|
+ // Check if the transaction is active commit it
|
|
|
if fSqlTrans.Active then
|
|
|
begin
|
|
|
fSqlTrans.CommitRetaining;
|
|
@@ -1717,8 +1714,8 @@ begin
|
|
|
// Initialize new instance of IBConnection and SQLTransaction
|
|
|
ibConnection:= TIBConnection.Create(nil);
|
|
|
fSqlTrans:= TSQLTransaction.Create(nil);
|
|
|
- fSQLQuery:= TSQLQuery.Create(nil);
|
|
|
- fSQLScript:= TSQLScript.Create(nil);
|
|
|
+ FSQLQuery:= TSQLQuery.Create(nil);
|
|
|
+ FSQLScript:= TSQLScript.Create(nil);
|
|
|
SynCompletion1.ItemList.CommaText:= 'create,table,Select,From,INTEGER,FLOAT';
|
|
|
SortSynCompletion;
|
|
|
end;
|
|
@@ -1726,8 +1723,8 @@ end;
|
|
|
procedure TfmQueryWindow.FormDestroy(Sender: TObject);
|
|
|
begin
|
|
|
// Clean up resources to avoid memory leaks
|
|
|
- fSQLQuery.Free;
|
|
|
- fSQLScript.Free;
|
|
|
+ FSQLQuery.Free;
|
|
|
+ FSQLScript.Free;
|
|
|
fSqlTrans.Free;
|
|
|
IBConnection.Free;
|
|
|
FList.Free;
|
|
@@ -2101,12 +2098,12 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-{ Execute query according to passed query type }
|
|
|
+{ Execute query according to passed query ype }
|
|
|
|
|
|
procedure TfmQueryWindow.CallExecuteQuery(aQueryType: TQueryTypes);
|
|
|
begin
|
|
|
// Get query text from memo
|
|
|
- fQuery:= GetQuery;
|
|
|
+ fQuery:= Trim(GetQuery);
|
|
|
fList.Text:= fQuery;
|
|
|
fStartLine:= 0;
|
|
|
|