Implement fetching multiple results from one query, e.g. from a procedure call. Fixes remaining stuff in issue #1135.

This commit is contained in:
Ansgar Becker
2010-08-28 15:17:10 +00:00
parent 68eea80072
commit b87745d0d3
2 changed files with 49 additions and 23 deletions

View File

@ -2175,24 +2175,19 @@ begin
ShowStatusMsg('Executing query #'+FormatNumber(i+1)+' of '+FormatNumber(SQLBatch.Count)+' ...');
ProgressBarStatus.StepIt;
ProgressBarStatus.Repaint;
Results := TMySQLQuery.Create(Self);
Results.Connection := Connection;
Results.LogCategory := lcUserFiredSQL;
Results.SQL := SQLBatch[i].SQL;
Results.StoreResult := QueryTab.ResultTabs.Count < prefMaxQueryResults;
try
Results.Execute;
Connection.Query(SQLBatch[i].SQL, QueryTab.ResultTabs.Count < prefMaxQueryResults, lcUserFiredSQL);
Inc(QueryCount);
Inc(SQLtime, Connection.LastQueryDuration);
Inc(SQLNetTime, Connection.LastQueryNetworkDuration);
Inc(RowsAffected, Connection.RowsAffected);
Inc(RowsFound, Connection.RowsFound);
if Results.StoreResult and Results.HasResult then begin
if (Connection.ResultCount > 0) then for Results in Connection.GetLastResults do begin
NewTab := TResultTab.Create;
QueryTab.ResultTabs.Add(NewTab);
NewTab.Results := Results;
try
TabCaption := Results.TableName;
TabCaption := NewTab.Results.TableName;
except on E:EDatabaseError do
TabCaption := 'Result #'+IntToStr(QueryTab.ResultTabs.Count);
end;
@ -2220,8 +2215,7 @@ begin
NewTab.Grid.EndUpdate;
for j:=0 to NewTab.Grid.Header.Columns.Count-1 do
AutoCalcColWidth(NewTab.Grid, j);
end else
FreeAndNil(Results);
end;
except
on E:EDatabaseError do begin
if actQueryStopOnErrors.Checked or (i = SQLBatch.Count - 1) then begin