|
@@ -32,9 +32,9 @@ type
|
|
|
|
|
|
TQueryThread = class(TThread)
|
|
TQueryThread = class(TThread)
|
|
private
|
|
private
|
|
- fSQLQuery: TSQLQuery;
|
|
|
|
- fTrans: TSQLTransaction;
|
|
|
|
- fConnection: TIBConnection;
|
|
|
|
|
|
+ FSQLQuery: TSQLQuery;
|
|
|
|
+ FTrans: TSQLTransaction;
|
|
|
|
+ FConnection: TIBConnection;
|
|
|
|
|
|
public
|
|
public
|
|
Error: Boolean;
|
|
Error: Boolean;
|
|
@@ -42,9 +42,9 @@ type
|
|
fTerminated: Boolean;
|
|
fTerminated: Boolean;
|
|
fType: TQueryActions;
|
|
fType: TQueryActions;
|
|
fStatement: string;
|
|
fStatement: string;
|
|
- property Query: TSQLQuery read fSQLQuery write fSQLQuery;
|
|
|
|
- property Trans: TSQLTransaction read fTrans write fTrans;
|
|
|
|
- property Connection: TIBConnection read fConnection write fConnection;
|
|
|
|
|
|
+ property Query: TSQLQuery read FSQLQuery write FSQLQuery;
|
|
|
|
+ property Trans: TSQLTransaction read FTrans write FTrans;
|
|
|
|
+ property Connection: TIBConnection read FConnection write FConnection;
|
|
property Statement: String read fStatement write fStatement;
|
|
property Statement: String read fStatement write fStatement;
|
|
procedure DoJob;
|
|
procedure DoJob;
|
|
procedure Execute; override;
|
|
procedure Execute; override;
|
|
@@ -161,29 +161,29 @@ type
|
|
procedure tbSaveClick(Sender: TObject);
|
|
procedure tbSaveClick(Sender: TObject);
|
|
private
|
|
private
|
|
{ private declarations }
|
|
{ private declarations }
|
|
- fdbIndex: Integer; // Index of selected registered database
|
|
|
|
- RegRec: TRegisteredDatabase;
|
|
|
|
- fResultControls: array of TObject;
|
|
|
|
- fParentResultControls: array of TObject;
|
|
|
|
- fOptions: set of TSynSearchOption;
|
|
|
|
- ibConnection: TIBConnection;
|
|
|
|
- fSqlTrans: TSQLTransaction;
|
|
|
|
- fCanceled: Boolean;
|
|
|
|
- fStartLine: Integer;
|
|
|
|
- fQuery: TStringList; //query text
|
|
|
|
- fOrigQueryType: TQueryTypes;
|
|
|
|
- fFinished: Boolean;
|
|
|
|
- fQT: TQueryThread;
|
|
|
|
- fQueryPart: string;
|
|
|
|
- fTab: TTabSheet;
|
|
|
|
- fmeResult: TMemo;
|
|
|
|
- fSqlQuery: TSQLQuery;
|
|
|
|
- fSqlScript: TModSQLScript;
|
|
|
|
|
|
+ FDBIndex: Integer; // Index of selected registered database
|
|
|
|
+ FRegRec: TRegisteredDatabase;
|
|
|
|
+ FResultControls: array of TObject;
|
|
|
|
+ FParentResultControls: array of TObject;
|
|
|
|
+ FOptions: set of TSynSearchOption;
|
|
|
|
+ FIBConnection: TIBConnection;
|
|
|
|
+ FSQLTrans: TSQLTransaction;
|
|
|
|
+ FCanceled: Boolean;
|
|
|
|
+ FStartLine: Integer;
|
|
|
|
+ FQuery: TStringList; //query text
|
|
|
|
+ FOrigQueryType: TQueryTypes;
|
|
|
|
+ FFinished: Boolean;
|
|
|
|
+ FQT: TQueryThread;
|
|
|
|
+ FQueryPart: string;
|
|
|
|
+ FTab: TTabSheet;
|
|
|
|
+ FResultMemo: TMemo;
|
|
|
|
+ FSQLQuery: TSQLQuery;
|
|
|
|
+ FSQLScript: TModSQLScript;
|
|
// Text for caption
|
|
// Text for caption
|
|
- faText: string;
|
|
|
|
- fModifyCount: Integer;
|
|
|
|
- fCnt: Integer;
|
|
|
|
- fModifiedRecords: array of array of Integer;
|
|
|
|
|
|
+ FAText: string;
|
|
|
|
+ FModifyCount: Integer;
|
|
|
|
+ FCounter: Integer;
|
|
|
|
+ FModifiedRecords: array of array of Integer;
|
|
|
|
|
|
procedure EnableCommitButton;
|
|
procedure EnableCommitButton;
|
|
procedure ExecuteQuery;
|
|
procedure ExecuteQuery;
|
|
@@ -368,15 +368,15 @@ var
|
|
Exists: Boolean;
|
|
Exists: Boolean;
|
|
begin
|
|
begin
|
|
Exists:= False;
|
|
Exists:= False;
|
|
- if TabIndex > High(fModifiedRecords) then // Insert new tab
|
|
|
|
|
|
+ if TabIndex > High(FModifiedRecords) then // Insert new tab
|
|
begin
|
|
begin
|
|
- SetLength(fModifiedRecords, TabIndex + 1);
|
|
|
|
|
|
+ SetLength(FModifiedRecords, TabIndex + 1);
|
|
end;
|
|
end;
|
|
|
|
|
|
// Check if record already inserted
|
|
// Check if record already inserted
|
|
- for i:= 0 to High(fModifiedRecords[TabIndex]) do
|
|
|
|
|
|
+ for i:= 0 to High(FModifiedRecords[TabIndex]) do
|
|
begin
|
|
begin
|
|
- if fModifiedRecords[TabIndex][i] = RecordNo then
|
|
|
|
|
|
+ if FModifiedRecords[TabIndex][i] = RecordNo then
|
|
begin
|
|
begin
|
|
Exists:= True;
|
|
Exists:= True;
|
|
Break;
|
|
Break;
|
|
@@ -385,12 +385,12 @@ begin
|
|
|
|
|
|
if not Exists then // Insert record pointer
|
|
if not Exists then // Insert record pointer
|
|
begin
|
|
begin
|
|
- setLength(fModifiedRecords[TabIndex], Length(fModifiedRecords[TabIndex]) + 1);
|
|
|
|
- fModifiedRecords[TabIndex][High(fModifiedRecords[TabIndex])]:= RecordNo;
|
|
|
|
|
|
+ setLength(FModifiedRecords[TabIndex], Length(FModifiedRecords[TabIndex]) + 1);
|
|
|
|
+ FModifiedRecords[TabIndex][High(FModifiedRecords[TabIndex])]:= RecordNo;
|
|
end;
|
|
end;
|
|
|
|
|
|
// Enable apply/save button
|
|
// Enable apply/save button
|
|
- if Length(fModifiedRecords[TabIndex]) = 1 then
|
|
|
|
|
|
+ if Length(FModifiedRecords[TabIndex]) = 1 then
|
|
begin
|
|
begin
|
|
EnableApplyButton;
|
|
EnableApplyButton;
|
|
end;
|
|
end;
|
|
@@ -419,27 +419,27 @@ begin
|
|
RecordSet:= GetRecordSet(TabIndex);
|
|
RecordSet:= GetRecordSet(TabIndex);
|
|
|
|
|
|
// Get primary key name
|
|
// Get primary key name
|
|
- PKIndexName:= fmMain.GetPrimaryKeyIndexName(fdbIndex, ATableName, ConstraintName);
|
|
|
|
|
|
+ PKIndexName:= fmMain.GetPrimaryKeyIndexName(FDBIndex, ATableName, ConstraintName);
|
|
if PKIndexName <> '' then
|
|
if PKIndexName <> '' then
|
|
begin
|
|
begin
|
|
KeyList:= TStringList.Create;
|
|
KeyList:= TStringList.Create;
|
|
Fieldslist:= TStringList.Create;
|
|
Fieldslist:= TStringList.Create;
|
|
aQuery:= TSQLQuery.Create(nil);
|
|
aQuery:= TSQLQuery.Create(nil);
|
|
try
|
|
try
|
|
- aQuery.DataBase:= ibConnection;
|
|
|
|
- aQuery.Transaction:= fSqlTrans;
|
|
|
|
|
|
+ aQuery.DataBase:= FIBConnection;
|
|
|
|
+ aQuery.Transaction:= FSQLTrans;
|
|
|
|
|
|
// Get primary key fields
|
|
// Get primary key fields
|
|
fmMain.GetIndexFields(ATableName, PKIndexName, aQuery, KeyList);
|
|
fmMain.GetIndexFields(ATableName, PKIndexName, aQuery, KeyList);
|
|
- fmMain.GetFields(fdbIndex, ATableName, FieldsList);
|
|
|
|
|
|
+ fmMain.GetFields(FDBIndex, ATableName, FieldsList);
|
|
WhereClause:= 'where ';
|
|
WhereClause:= 'where ';
|
|
|
|
|
|
RecordSet.DisableControls;
|
|
RecordSet.DisableControls;
|
|
// Check modified fields
|
|
// Check modified fields
|
|
- for i:= Low(fModifiedRecords[TabIndex]) to High(fModifiedRecords[TabIndex]) do
|
|
|
|
|
|
+ for i:= Low(FModifiedRecords[TabIndex]) to High(FModifiedRecords[TabIndex]) do
|
|
begin
|
|
begin
|
|
FieldsSQL:= '';
|
|
FieldsSQL:= '';
|
|
- RecordSet.RecNo:= fModifiedRecords[TabIndex][i];
|
|
|
|
|
|
+ RecordSet.RecNo:= FModifiedRecords[TabIndex][i];
|
|
for x:= 0 to RecordSet.Fields.Count - 1 do
|
|
for x:= 0 to RecordSet.Fields.Count - 1 do
|
|
begin
|
|
begin
|
|
if (FieldsList.IndexOf(RecordSet.Fields[x].FieldName) <> -1) and // Field exist in origional table
|
|
if (FieldsList.IndexOf(RecordSet.Fields[x].FieldName) <> -1) and // Field exist in origional table
|
|
@@ -493,14 +493,14 @@ begin
|
|
|
|
|
|
// Auto commit
|
|
// Auto commit
|
|
if cxAutoCommit.Checked then
|
|
if cxAutoCommit.Checked then
|
|
- fSqlTrans.CommitRetaining
|
|
|
|
|
|
+ FSQLTrans.CommitRetaining
|
|
else
|
|
else
|
|
EnableCommitButton;
|
|
EnableCommitButton;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- // Reset fModifiedRecords pointer
|
|
|
|
- fModifiedRecords[TabIndex]:= nil;
|
|
|
|
|
|
+ // Reset FModifiedRecords pointer
|
|
|
|
+ FModifiedRecords[TabIndex]:= nil;
|
|
RecordSet.EnableControls;
|
|
RecordSet.EnableControls;
|
|
finally
|
|
finally
|
|
FieldsList.Free;
|
|
FieldsList.Free;
|
|
@@ -524,11 +524,11 @@ procedure TfmQueryWindow.EnableApplyButton;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
- if (fResultControls[i] is TBitBtn) and ((fResultControls[i] as TBitBtn).Tag = PageControl1.TabIndex) and
|
|
|
|
- ((fResultControls[i] as TBitBtn).Caption = 'Apply') then
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
|
|
+ if (FResultControls[i] is TBitBtn) and ((FResultControls[i] as TBitBtn).Tag = PageControl1.TabIndex) and
|
|
|
|
+ ((FResultControls[i] as TBitBtn).Caption = 'Apply') then
|
|
begin
|
|
begin
|
|
- (fResultControls[i] as TBitBtn).Visible:= True;
|
|
|
|
|
|
+ (FResultControls[i] as TBitBtn).Visible:= True;
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -540,11 +540,11 @@ procedure TfmQueryWindow.EnableCommitButton;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
- if (fResultControls[i] is TBitBtn) and ((fResultControls[i] as TBitBtn).Tag = PageControl1.TabIndex)
|
|
|
|
- and ((fResultControls[i] as TBitBtn).Caption = 'Commit') then
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
|
|
+ if (FResultControls[i] is TBitBtn) and ((FResultControls[i] as TBitBtn).Tag = PageControl1.TabIndex)
|
|
|
|
+ and ((FResultControls[i] as TBitBtn).Caption = 'Commit') then
|
|
begin
|
|
begin
|
|
- (fResultControls[i] as TBitBtn).Visible:= True;
|
|
|
|
|
|
+ (FResultControls[i] as TBitBtn).Visible:= True;
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -579,11 +579,11 @@ function TfmQueryWindow.GetCurrentSQLText: string;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
begin
|
|
begin
|
|
- if (fResultControls[i] is TDBGrid) and ((fResultControls[i] as TDBGrid).Tag = PageControl1.TabIndex) then
|
|
|
|
|
|
+ if (FResultControls[i] is TDBGrid) and ((FResultControls[i] as TDBGrid).Tag = PageControl1.TabIndex) then
|
|
begin
|
|
begin
|
|
- Result:= ((fResultControls[i] as TDBGrid).DataSource.DataSet as TSQLQuery).SQL.Text;
|
|
|
|
|
|
+ Result:= ((FResultControls[i] as TDBGrid).DataSource.DataSet as TSQLQuery).SQL.Text;
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -594,7 +594,7 @@ end;
|
|
|
|
|
|
procedure TfmQueryWindow.CommitResultClick(Sender: TObject);
|
|
procedure TfmQueryWindow.CommitResultClick(Sender: TObject);
|
|
begin
|
|
begin
|
|
- fSqlTrans.CommitRetaining;
|
|
|
|
|
|
+ FSQLTrans.CommitRetaining;
|
|
(Sender as TBitBtn).Visible:= False;
|
|
(Sender as TBitBtn).Visible:= False;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -623,12 +623,12 @@ function TfmQueryWindow.GetRecordSet(TabIndex: Integer): TSQLQuery;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
begin
|
|
begin
|
|
- if (fResultControls[i] is TSQLQuery) and
|
|
|
|
- ((fResultControls[i] as TSQLQuery).Tag = TabIndex) then
|
|
|
|
|
|
+ if (FResultControls[i] is TSQLQuery) and
|
|
|
|
+ ((FResultControls[i] as TSQLQuery).Tag = TabIndex) then
|
|
begin
|
|
begin
|
|
- Result:= fResultControls[i] as TSQLQuery;
|
|
|
|
|
|
+ Result:= FResultControls[i] as TSQLQuery;
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -679,25 +679,25 @@ procedure TQueryThread.DoJob;
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
if fType = qaOpen then
|
|
if fType = qaOpen then
|
|
- fSQLQuery.Open
|
|
|
|
|
|
+ FSQLQuery.Open
|
|
else
|
|
else
|
|
if fType = qaExec then
|
|
if fType = qaExec then
|
|
- fSQLQuery.ExecSQL
|
|
|
|
|
|
+ FSQLQuery.ExecSQL
|
|
else
|
|
else
|
|
if fType = qaDDL then
|
|
if fType = qaDDL then
|
|
- fConnection.ExecuteDirect(fStatement)
|
|
|
|
|
|
+ FConnection.ExecuteDirect(fStatement)
|
|
else
|
|
else
|
|
if fType = qaCommit then
|
|
if fType = qaCommit then
|
|
- fTrans.Commit
|
|
|
|
|
|
+ FTrans.Commit
|
|
else
|
|
else
|
|
if fType = qaCommitRet then
|
|
if fType = qaCommitRet then
|
|
- fTrans.CommitRetaining
|
|
|
|
|
|
+ FTrans.CommitRetaining
|
|
else
|
|
else
|
|
if fType = qaRollBack then
|
|
if fType = qaRollBack then
|
|
- fTrans.Rollback
|
|
|
|
|
|
+ FTrans.Rollback
|
|
else
|
|
else
|
|
if fType = qaRollbackRet then
|
|
if fType = qaRollbackRet then
|
|
- fTrans.RollbackRetaining;
|
|
|
|
|
|
+ FTrans.RollbackRetaining;
|
|
|
|
|
|
Error:= False;
|
|
Error:= False;
|
|
fTerminated:= True;
|
|
fTerminated:= True;
|
|
@@ -781,7 +781,7 @@ begin
|
|
ATab:= CreateResultTab(qtExecute, SqlQuery, SqlScript, meResult);
|
|
ATab:= CreateResultTab(qtExecute, SqlQuery, SqlScript, meResult);
|
|
QT:= TQueryThread.Create(qaCommit);
|
|
QT:= TQueryThread.Create(qaCommit);
|
|
try
|
|
try
|
|
- QT.Trans:= fSqlTrans;
|
|
|
|
|
|
+ QT.Trans:= FSQLTrans;
|
|
ATab.ImageIndex:= 6;
|
|
ATab.ImageIndex:= 6;
|
|
|
|
|
|
// Run thread
|
|
// Run thread
|
|
@@ -823,7 +823,7 @@ var
|
|
begin
|
|
begin
|
|
QT:= TQueryThread.Create(qaCommitRet);
|
|
QT:= TQueryThread.Create(qaCommitRet);
|
|
try
|
|
try
|
|
- QT.Trans:= fSqlTrans;
|
|
|
|
|
|
+ QT.Trans:= FSQLTrans;
|
|
|
|
|
|
// Run thread
|
|
// Run thread
|
|
QT.Resume;
|
|
QT.Resume;
|
|
@@ -851,7 +851,7 @@ end;
|
|
|
|
|
|
procedure TfmQueryWindow.tbHistoryClick(Sender: TObject);
|
|
procedure TfmQueryWindow.tbHistoryClick(Sender: TObject);
|
|
begin
|
|
begin
|
|
- fmSQLHistory.Init(RegRec.Title, Self);
|
|
|
|
|
|
+ fmSQLHistory.Init(FRegRec.Title, Self);
|
|
fmSQLHistory.Show;
|
|
fmSQLHistory.Show;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -873,9 +873,9 @@ begin
|
|
// Get a free number to be assigned to the new Query window
|
|
// Get a free number to be assigned to the new Query window
|
|
for i:= 1 to 1000 do
|
|
for i:= 1 to 1000 do
|
|
begin
|
|
begin
|
|
- if fmMain.FindQueryWindow(RegRec.Title + ': Query Window # ' + IntToStr(i)) = nil then
|
|
|
|
|
|
+ if fmMain.FindQueryWindow(FRegRec.Title + ': Query Window # ' + IntToStr(i)) = nil then
|
|
begin
|
|
begin
|
|
- fmMain.ShowCompleteQueryWindow(fdbIndex, 'Query Window # ' + IntToStr(i), '');
|
|
|
|
|
|
+ fmMain.ShowCompleteQueryWindow(FDBIndex, 'Query Window # ' + IntToStr(i), '');
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -905,7 +905,7 @@ begin
|
|
ATab:= CreateResultTab(qtExecute, SqlQuery, SqlScript, meResult);
|
|
ATab:= CreateResultTab(qtExecute, SqlQuery, SqlScript, meResult);
|
|
QT:= TQueryThread.Create(qaRollBack);
|
|
QT:= TQueryThread.Create(qaRollBack);
|
|
try
|
|
try
|
|
- QT.Trans:= fSqlTrans;
|
|
|
|
|
|
+ QT.Trans:= FSQLTrans;
|
|
ATab.ImageIndex:= 6;
|
|
ATab.ImageIndex:= 6;
|
|
QT.Resume;
|
|
QT.Resume;
|
|
repeat
|
|
repeat
|
|
@@ -943,12 +943,12 @@ var
|
|
begin
|
|
begin
|
|
QT:= TQueryThread.Create(qaRollbackRet);
|
|
QT:= TQueryThread.Create(qaRollbackRet);
|
|
try
|
|
try
|
|
- QT.Trans:= fSqlTrans;
|
|
|
|
|
|
+ QT.Trans:= FSQLTrans;
|
|
|
|
|
|
QT.Resume;
|
|
QT.Resume;
|
|
repeat
|
|
repeat
|
|
application.ProcessMessages;
|
|
application.ProcessMessages;
|
|
- until QT.fTerminated or (fCanceled);
|
|
|
|
|
|
+ until QT.fTerminated or (FCanceled);
|
|
if QT.Error then
|
|
if QT.Error then
|
|
ShowMessage(QT.ErrorMsg);
|
|
ShowMessage(QT.ErrorMsg);
|
|
finally
|
|
finally
|
|
@@ -993,21 +993,21 @@ end;
|
|
|
|
|
|
procedure TfmQueryWindow.Init(dbIndex: Integer);
|
|
procedure TfmQueryWindow.Init(dbIndex: Integer);
|
|
begin
|
|
begin
|
|
- fdbIndex:= dbIndex;
|
|
|
|
- RegRec:= fmMain.RegisteredDatabases[dbIndex].RegRec;
|
|
|
|
|
|
+ FDBIndex:= dbIndex;
|
|
|
|
+ FRegRec:= fmMain.RegisteredDatabases[dbIndex].RegRec;
|
|
|
|
|
|
- // Set instances of IBConnection and SQLTransaction for the current Query Window
|
|
|
|
- fmMain.setTransactionIsolation(fSqlTrans.Params);
|
|
|
|
- fSqlTrans.DataBase:= ibConnection;
|
|
|
|
|
|
+ // Set instances of FIBConnection and SQLTransaction for the current Query Window
|
|
|
|
+ fmMain.setTransactionIsolation(FSQLTrans.Params);
|
|
|
|
+ FSQLTrans.DataBase:= FIBConnection;
|
|
|
|
|
|
- // Set connection parameters to IBConnection
|
|
|
|
|
|
+ // Set connection parameters to FIBConnection
|
|
with fmMain.RegisteredDatabases[dbIndex] do
|
|
with fmMain.RegisteredDatabases[dbIndex] do
|
|
begin
|
|
begin
|
|
- Self.ibConnection.DatabaseName:= RegRec.DatabaseName;
|
|
|
|
- Self.ibConnection.UserName:= RegRec.UserName;
|
|
|
|
- Self.ibConnection.Password:= RegRec.Password;
|
|
|
|
- Self.IBConnection.CharSet:= RegRec.Charset;
|
|
|
|
- Self.ibConnection.Role:= RegRec.Role;
|
|
|
|
|
|
+ Self.FIBConnection.DatabaseName:= RegRec.DatabaseName;
|
|
|
|
+ Self.FIBConnection.UserName:= RegRec.UserName;
|
|
|
|
+ Self.FIBConnection.Password:= RegRec.Password;
|
|
|
|
+ Self.FIBConnection.CharSet:= RegRec.Charset;
|
|
|
|
+ Self.FIBConnection.Role:= RegRec.Role;
|
|
end;
|
|
end;
|
|
|
|
|
|
// Get current database tables to be hilighted in SQL query editor
|
|
// Get current database tables to be hilighted in SQL query editor
|
|
@@ -1109,8 +1109,8 @@ begin
|
|
begin
|
|
begin
|
|
// Query
|
|
// Query
|
|
aSqlQuery:= TSQLQuery.Create(self);
|
|
aSqlQuery:= TSQLQuery.Create(self);
|
|
- aSqlQuery.DataBase:= ibConnection;
|
|
|
|
- aSqlQuery.Transaction:= fSqlTrans;
|
|
|
|
|
|
+ aSqlQuery.DataBase:= FIBConnection;
|
|
|
|
+ aSqlQuery.Transaction:= FSQLTrans;
|
|
aSqlQuery.AfterScroll:= @QueryAfterScroll;
|
|
aSqlQuery.AfterScroll:= @QueryAfterScroll;
|
|
aSqlQuery.AfterPost:= @FinishCellEditing;
|
|
aSqlQuery.AfterPost:= @FinishCellEditing;
|
|
aSqlQuery.Tag:= ATab.TabIndex;
|
|
aSqlQuery.Tag:= ATab.TabIndex;
|
|
@@ -1169,14 +1169,14 @@ begin
|
|
qtExecute:
|
|
qtExecute:
|
|
begin
|
|
begin
|
|
aSqlQuery:= TSQLQuery.Create(self);
|
|
aSqlQuery:= TSQLQuery.Create(self);
|
|
- aSqlQuery.DataBase:= ibConnection;
|
|
|
|
- aSqlQuery.Transaction:= fSqlTrans;
|
|
|
|
|
|
+ aSqlQuery.DataBase:= FIBConnection;
|
|
|
|
+ aSqlQuery.Transaction:= FSQLTrans;
|
|
end;
|
|
end;
|
|
qtScript: // Script
|
|
qtScript: // Script
|
|
begin
|
|
begin
|
|
aSQLScript:= TModSQLScript.Create(self);
|
|
aSQLScript:= TModSQLScript.Create(self);
|
|
- aSQLScript.DataBase:= ibConnection;
|
|
|
|
- aSQLScript.Transaction:= fSqlTrans;
|
|
|
|
|
|
+ aSQLScript.DataBase:= FIBConnection;
|
|
|
|
+ aSQLScript.Transaction:= FSQLTrans;
|
|
aSQLScript.CommentsInSQL:= true;
|
|
aSQLScript.CommentsInSQL:= true;
|
|
aSQLScript.UseSetTerm:= true; //needed if set term is used, e.g. for stored procedures
|
|
aSQLScript.UseSetTerm:= true; //needed if set term is used, e.g. for stored procedures
|
|
end;
|
|
end;
|
|
@@ -1198,240 +1198,240 @@ var
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
// Script
|
|
// Script
|
|
- if (fOrigQueryType = qtScript) then
|
|
|
|
|
|
+ if (FOrigQueryType = qtScript) then
|
|
begin // script
|
|
begin // script
|
|
- ExecuteScript(fQuery.Text);
|
|
|
|
- Inc(fModifyCount);
|
|
|
|
- SqlType:= GetSQLType(fQuery.Text, Command);
|
|
|
|
- fmMain.AddToSQLHistory(RegRec.Title, SqlType, fQuery.Text);
|
|
|
|
- fFinished:= True;
|
|
|
|
- fQuery.Clear;
|
|
|
|
|
|
+ ExecuteScript(FQuery.Text);
|
|
|
|
+ Inc(FModifyCount);
|
|
|
|
+ SqlType:= GetSQLType(FQuery.Text, Command);
|
|
|
|
+ fmMain.AddToSQLHistory(FRegRec.Title, SqlType, FQuery.Text);
|
|
|
|
+ FFinished:= True;
|
|
|
|
+ FQuery.Clear;
|
|
end
|
|
end
|
|
else // normal statement / Multi statements
|
|
else // normal statement / Multi statements
|
|
begin
|
|
begin
|
|
- Inc(fCnt);
|
|
|
|
- if not GetSQLSegment(fQuery, fStartline, fQueryType, EndLine, fQueryPart, IsDDL) then
|
|
|
|
|
|
+ Inc(FCounter);
|
|
|
|
+ if not GetSQLSegment(FQuery, FStartLine, fQueryType, EndLine, FQueryPart, IsDDL) then
|
|
begin
|
|
begin
|
|
- fFinished:= True;
|
|
|
|
|
|
+ FFinished:= True;
|
|
Exit;
|
|
Exit;
|
|
end;
|
|
end;
|
|
|
|
|
|
- {if EndLine < fStartLine then
|
|
|
|
- fStartLine:= fStartLine + 1
|
|
|
|
|
|
+ {if EndLine < FStartLine then
|
|
|
|
+ FStartLine:= FStartLine + 1
|
|
else}
|
|
else}
|
|
- fStartLine:= EndLine + 1;
|
|
|
|
|
|
+ FStartLine:= EndLine + 1;
|
|
|
|
|
|
- if Trim(fQueryPart) <> '' then // Select
|
|
|
|
|
|
+ if Trim(FQueryPart) <> '' then // Select
|
|
if fQueryType = qtSelectable then
|
|
if fQueryType = qtSelectable then
|
|
begin
|
|
begin
|
|
- fTab:= nil;
|
|
|
|
|
|
+ FTab:= nil;
|
|
try
|
|
try
|
|
- fTab:= CreateResultTab(qtSelectable, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- fTab.ImageIndex:= 6;
|
|
|
|
- fTab.Hint:= fQueryPart;
|
|
|
|
- fTab.ShowHint:= True;
|
|
|
|
- fSQLQuery.SQL.Text:= fQueryPart;
|
|
|
|
|
|
+ FTab:= CreateResultTab(qtSelectable, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ FTab.ImageIndex:= 6;
|
|
|
|
+ FTab.Hint:= FQueryPart;
|
|
|
|
+ FTab.ShowHint:= True;
|
|
|
|
+ FSQLQuery.SQL.Text:= FQueryPart;
|
|
|
|
|
|
// Create thread to open dataset
|
|
// Create thread to open dataset
|
|
- fQT:= TQueryThread.Create(qaOpen);
|
|
|
|
- fQT.Query:= fSqlQuery;
|
|
|
|
- // fQT.OnTerminate:= @ThreadTerminated;
|
|
|
|
- faText:= fTab.Caption;
|
|
|
|
- fTab.Caption:= 'Running..';
|
|
|
|
- fQT.Resume;
|
|
|
|
|
|
+ FQT:= TQueryThread.Create(qaOpen);
|
|
|
|
+ FQT.Query:= FSQLQuery;
|
|
|
|
+ // FQT.OnTerminate:= @ThreadTerminated;
|
|
|
|
+ FAText:= FTab.Caption;
|
|
|
|
+ FTab.Caption:= 'Running..';
|
|
|
|
+ FQT.Resume;
|
|
|
|
|
|
// Wait for the thread to complete
|
|
// Wait for the thread to complete
|
|
repeat
|
|
repeat
|
|
Sleep(100);
|
|
Sleep(100);
|
|
application.ProcessMessages; // This prevents display freeze
|
|
application.ProcessMessages; // This prevents display freeze
|
|
- until fQT.fTerminated;
|
|
|
|
|
|
+ until FQT.fTerminated;
|
|
|
|
|
|
// Raise exception if an error occured during thread execution (Open)
|
|
// Raise exception if an error occured during thread execution (Open)
|
|
- if fQT.Error then
|
|
|
|
- raise Exception.Create(fQT.ErrorMsg);
|
|
|
|
|
|
+ if FQT.Error then
|
|
|
|
+ raise Exception.Create(FQT.ErrorMsg);
|
|
|
|
|
|
- fQT.Free;
|
|
|
|
- fTab.Caption:= faText;
|
|
|
|
- fTab.ImageIndex:= 0;
|
|
|
|
- fmMain.AddToSQLHistory(RegRec.Title, 'SELECT', fQueryPart);
|
|
|
|
|
|
+ FQT.Free;
|
|
|
|
+ FTab.Caption:= FAText;
|
|
|
|
+ FTab.ImageIndex:= 0;
|
|
|
|
+ fmMain.AddToSQLHistory(FRegRec.Title, 'SELECT', FQueryPart);
|
|
except
|
|
except
|
|
on e: Exception do
|
|
on e: Exception do
|
|
begin
|
|
begin
|
|
- if Assigned(fTab) then
|
|
|
|
- fTab.TabVisible:= False;
|
|
|
|
- SetLength(fResultControls, High(fResultControls));
|
|
|
|
- SetLength(fParentResultControls, High(fParentResultControls));
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- PageControl1.ActivePage:= fTab;
|
|
|
|
-
|
|
|
|
- fmeResult.Text:= e.message;
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
- fmeResult.Font.Color:= clRed;
|
|
|
|
- fTab.Font.Color:= clRed;
|
|
|
|
- fTab.ImageIndex:= 3;
|
|
|
|
|
|
+ if Assigned(FTab) then
|
|
|
|
+ FTab.TabVisible:= False;
|
|
|
|
+ SetLength(FResultControls, High(FResultControls));
|
|
|
|
+ SetLength(FParentResultControls, High(FParentResultControls));
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ PageControl1.ActivePage:= FTab;
|
|
|
|
+
|
|
|
|
+ FResultMemo.Text:= e.message;
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
|
|
+ FResultMemo.Font.Color:= clRed;
|
|
|
|
+ FTab.Font.Color:= clRed;
|
|
|
|
+ FTab.ImageIndex:= 3;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
else // Execute
|
|
else // Execute
|
|
if fQueryType = qtExecute then
|
|
if fQueryType = qtExecute then
|
|
begin
|
|
begin
|
|
- fTab:= nil;
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
|
|
+ FTab:= nil;
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
|
|
- fTab.ImageIndex:= 1;
|
|
|
|
- SqlType:= GetSQLType(fQueryPart, Command);
|
|
|
|
|
|
+ FTab.ImageIndex:= 1;
|
|
|
|
+ SqlType:= GetSQLType(FQueryPart, Command);
|
|
StartTime:= Now;
|
|
StartTime:= Now;
|
|
Affected:= 0;
|
|
Affected:= 0;
|
|
try
|
|
try
|
|
if IsDDL then
|
|
if IsDDL then
|
|
begin
|
|
begin
|
|
// Execute the statement in thread
|
|
// Execute the statement in thread
|
|
- fQT:= TQueryThread.Create(qaDDL);
|
|
|
|
- fQT.Connection:= ibConnection;
|
|
|
|
- fQT.Statement:= fQueryPart;
|
|
|
|
- fQT.Resume;
|
|
|
|
- faText:= fTab.Caption;
|
|
|
|
- fTab.Caption:= 'Running..';
|
|
|
|
|
|
+ FQT:= TQueryThread.Create(qaDDL);
|
|
|
|
+ FQT.Connection:= FIBConnection;
|
|
|
|
+ FQT.Statement:= FQueryPart;
|
|
|
|
+ FQT.Resume;
|
|
|
|
+ FAText:= FTab.Caption;
|
|
|
|
+ FTab.Caption:= 'Running..';
|
|
|
|
|
|
// Wait for thread completion
|
|
// Wait for thread completion
|
|
repeat
|
|
repeat
|
|
application.ProcessMessages;
|
|
application.ProcessMessages;
|
|
- until (fQT.fTerminated) or (fCanceled);
|
|
|
|
|
|
+ until (FQT.fTerminated) or (FCanceled);
|
|
|
|
|
|
// Raise exception if an error occured during thread execution (ExecProc)
|
|
// Raise exception if an error occured during thread execution (ExecProc)
|
|
- if fQT.Error then
|
|
|
|
- raise Exception.Create(fQT.ErrorMsg);
|
|
|
|
|
|
+ if FQT.Error then
|
|
|
|
+ raise Exception.Create(FQT.ErrorMsg);
|
|
|
|
|
|
- fTab.Caption:= faText;
|
|
|
|
|
|
+ FTab.Caption:= FAText;
|
|
|
|
|
|
// Auto commit
|
|
// Auto commit
|
|
if cxAutoCommit.Checked then
|
|
if cxAutoCommit.Checked then
|
|
- fSqlTrans.Commit;
|
|
|
|
- fQT.Free;
|
|
|
|
|
|
+ FSQLTrans.Commit;
|
|
|
|
+ FQT.Free;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin // DML
|
|
begin // DML
|
|
- fSqlQuery.Close;
|
|
|
|
- fSqlQuery.SQL.Text:= fQueryPart;
|
|
|
|
- fTab.ImageIndex:= 6;
|
|
|
|
- fTab.Hint:= fQueryPart;
|
|
|
|
- fTab.ShowHint:= True;
|
|
|
|
- fSQLQuery.SQL.Text:= fQueryPart;
|
|
|
|
|
|
+ FSQLQuery.Close;
|
|
|
|
+ FSQLQuery.SQL.Text:= FQueryPart;
|
|
|
|
+ FTab.ImageIndex:= 6;
|
|
|
|
+ FTab.Hint:= FQueryPart;
|
|
|
|
+ FTab.ShowHint:= True;
|
|
|
|
+ FSQLQuery.SQL.Text:= FQueryPart;
|
|
|
|
|
|
// Execute the statement in thread
|
|
// Execute the statement in thread
|
|
- fQT:= TQueryThread.Create(qaExec);
|
|
|
|
|
|
+ FQT:= TQueryThread.Create(qaExec);
|
|
try
|
|
try
|
|
- fQT.Query:= fSqlQuery;
|
|
|
|
- fQT.Resume;
|
|
|
|
- faText:= fTab.Caption;
|
|
|
|
- fTab.Caption:= 'Running..';
|
|
|
|
|
|
+ FQT.Query:= FSQLQuery;
|
|
|
|
+ FQT.Resume;
|
|
|
|
+ FAText:= FTab.Caption;
|
|
|
|
+ FTab.Caption:= 'Running..';
|
|
|
|
|
|
// Wait for thread completion
|
|
// Wait for thread completion
|
|
repeat
|
|
repeat
|
|
application.ProcessMessages;
|
|
application.ProcessMessages;
|
|
- until (fQT.fTerminated) or (fCanceled);
|
|
|
|
|
|
+ until (FQT.fTerminated) or (FCanceled);
|
|
|
|
|
|
// Raise exception if an error occured during thread execution (ExecProc)
|
|
// Raise exception if an error occured during thread execution (ExecProc)
|
|
- if fQT.Error then
|
|
|
|
- raise Exception.Create(fQT.ErrorMsg);
|
|
|
|
|
|
+ if FQT.Error then
|
|
|
|
+ raise Exception.Create(FQT.ErrorMsg);
|
|
|
|
|
|
// Auto commit
|
|
// Auto commit
|
|
if cxAutoCommit.Checked then
|
|
if cxAutoCommit.Checked then
|
|
- fSqlTrans.Commit;
|
|
|
|
|
|
+ FSQLTrans.Commit;
|
|
finally
|
|
finally
|
|
- fQT.Free;
|
|
|
|
|
|
+ FQT.Free;
|
|
end;
|
|
end;
|
|
- fTab.Caption:= faText;
|
|
|
|
- fTab.ImageIndex:= 1;
|
|
|
|
- Affected:= fsqlQuery.RowsAffected;
|
|
|
|
|
|
+ FTab.Caption:= FAText;
|
|
|
|
+ FTab.ImageIndex:= 1;
|
|
|
|
+ Affected:= FSQLQuery.RowsAffected;
|
|
end;
|
|
end;
|
|
- Inc(fModifyCount);
|
|
|
|
|
|
+ Inc(FModifyCount);
|
|
|
|
|
|
- fmMain.AddToSQLHistory(RegRec.Title, SQLType, fQueryPart);
|
|
|
|
- fmeResult.Visible:= True;
|
|
|
|
- fmeResult.Clear;
|
|
|
|
- fmeResult.Lines.Add('statement #' + IntToStr(fCnt));
|
|
|
|
|
|
+ fmMain.AddToSQLHistory(FRegRec.Title, SQLType, FQueryPart);
|
|
|
|
+ FResultMemo.Visible:= True;
|
|
|
|
+ FResultMemo.Clear;
|
|
|
|
+ FResultMemo.Lines.Add('statement #' + IntToStr(FCounter));
|
|
if IsDDL then
|
|
if IsDDL then
|
|
- fmeResult.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DDL Executed. Takes (H:M:S.MS) ' +
|
|
|
|
|
|
+ FResultMemo.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DDL Executed. Takes (H:M:S.MS) ' +
|
|
FormatDateTime('HH:nn:ss.z', Now - StartTime))
|
|
FormatDateTime('HH:nn:ss.z', Now - StartTime))
|
|
else // DML
|
|
else // DML
|
|
begin
|
|
begin
|
|
- fmeResult.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DML Executed. Takes (H:M:S.MS) ' +
|
|
|
|
|
|
+ FResultMemo.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DML Executed. Takes (H:M:S.MS) ' +
|
|
FormatDateTime('HH:nn:ss.z', Now - StartTime));
|
|
FormatDateTime('HH:nn:ss.z', Now - StartTime));
|
|
- fmeResult.Lines.Add('Rows affected: ' + Format('%3.0n', [Affected / 1]));
|
|
|
|
|
|
+ FResultMemo.Lines.Add('Rows affected: ' + Format('%3.0n', [Affected / 1]));
|
|
end;
|
|
end;
|
|
- fmeResult.Lines.Add('----');
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
|
|
+ FResultMemo.Lines.Add('----');
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
except
|
|
except
|
|
on e: exception do
|
|
on e: exception do
|
|
begin
|
|
begin
|
|
- if Assigned(fTab) then
|
|
|
|
- fTab.TabVisible:= False;
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- PageControl1.ActivePage:= fTab;
|
|
|
|
- fmeResult.Text:= e.message;
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
- fmeResult.Font.Color:= clRed;
|
|
|
|
- fTab.Font.Color:= clRed;
|
|
|
|
- fTab.ImageIndex:= 3;
|
|
|
|
|
|
+ if Assigned(FTab) then
|
|
|
|
+ FTab.TabVisible:= False;
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ PageControl1.ActivePage:= FTab;
|
|
|
|
+ FResultMemo.Text:= e.message;
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
|
|
+ FResultMemo.Font.Color:= clRed;
|
|
|
|
+ FTab.Font.Color:= clRed;
|
|
|
|
+ FTab.ImageIndex:= 3;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
else // Script
|
|
else // Script
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
- if ExecuteScript(fQueryPart) then
|
|
|
|
|
|
+ if ExecuteScript(FQueryPart) then
|
|
begin
|
|
begin
|
|
- Inc(fModifyCount);
|
|
|
|
- SqlType:= GetSQLType(fQueryPart, Command);
|
|
|
|
- fmMain.AddToSQLHistory(RegRec.Title, SqlType, fQueryPart);
|
|
|
|
|
|
+ Inc(FModifyCount);
|
|
|
|
+ SqlType:= GetSQLType(FQueryPart, Command);
|
|
|
|
+ fmMain.AddToSQLHistory(FRegRec.Title, SqlType, FQueryPart);
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
on e: exception do
|
|
on e: exception do
|
|
begin
|
|
begin
|
|
- if Assigned(fTab) then
|
|
|
|
- fTab.TabVisible:= False;
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- PageControl1.ActivePage:= fTab;
|
|
|
|
- fmeResult.Text:= e.message;
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
- fmeResult.Lines.Add('--------');
|
|
|
|
- fmeResult.Font.Color:= clRed;
|
|
|
|
- fTab.Font.Color:= clRed;
|
|
|
|
- fTab.ImageIndex:= 3;
|
|
|
|
|
|
+ if Assigned(FTab) then
|
|
|
|
+ FTab.TabVisible:= False;
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ PageControl1.ActivePage:= FTab;
|
|
|
|
+ FResultMemo.Text:= e.message;
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
|
|
+ FResultMemo.Lines.Add('--------');
|
|
|
|
+ FResultMemo.Font.Color:= clRed;
|
|
|
|
+ FTab.Font.Color:= clRed;
|
|
|
|
+ FTab.ImageIndex:= 3;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
- if (fModifyCount > 50) then
|
|
|
|
|
|
+ if (FModifyCount > 50) then
|
|
begin
|
|
begin
|
|
if (MessageDlg('Commit', 'There are too many transactions, do you want to commit',
|
|
if (MessageDlg('Commit', 'There are too many transactions, do you want to commit',
|
|
mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
|
mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
|
begin
|
|
begin
|
|
- fSqlTrans.CommitRetaining;
|
|
|
|
- fModifyCount:= 0;
|
|
|
|
|
|
+ FSQLTrans.CommitRetaining;
|
|
|
|
+ FModifyCount:= 0;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- fModifyCount:= 0;
|
|
|
|
|
|
+ FModifyCount:= 0;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
- if fStartLine >= fQuery.Count then
|
|
|
|
- fFinished:= True;
|
|
|
|
|
|
+ if FStartLine >= FQuery.Count then
|
|
|
|
+ FFinished:= True;
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
on e: exception do
|
|
on e: exception do
|
|
begin
|
|
begin
|
|
- if Assigned(fTab) then
|
|
|
|
- fTab.TabVisible:= False;
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- fTab.ImageIndex:= 2;
|
|
|
|
- PageControl1.ActivePage:= fTab;
|
|
|
|
-
|
|
|
|
- fmeResult.Text:= e.message;
|
|
|
|
- fmeResult.Lines.Add('--------');
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
- fmeResult.Font.Color:= clRed;
|
|
|
|
- fFinished:= True;
|
|
|
|
|
|
+ if Assigned(FTab) then
|
|
|
|
+ FTab.TabVisible:= False;
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ FTab.ImageIndex:= 2;
|
|
|
|
+ PageControl1.ActivePage:= FTab;
|
|
|
|
+
|
|
|
|
+ FResultMemo.Text:= e.message;
|
|
|
|
+ FResultMemo.Lines.Add('--------');
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
|
|
+ FResultMemo.Font.Color:= clRed;
|
|
|
|
+ FFinished:= True;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -1463,7 +1463,7 @@ begin
|
|
|
|
|
|
// Auto commit
|
|
// Auto commit
|
|
if cxAutoCommit.Checked then
|
|
if cxAutoCommit.Checked then
|
|
- fSqlTrans.Commit;
|
|
|
|
|
|
+ FSQLTrans.Commit;
|
|
|
|
|
|
Result:= True;
|
|
Result:= True;
|
|
meResult.Lines.Text:= FormatDateTime('hh:nn:ss.z', Now) + ' - Script Executed. It took (H:M:S.MS) ' +
|
|
meResult.Lines.Text:= FormatDateTime('hh:nn:ss.z', Now) + ' - Script Executed. It took (H:M:S.MS) ' +
|
|
@@ -1670,21 +1670,21 @@ end;
|
|
|
|
|
|
procedure TfmQueryWindow.FindDialog1Find(Sender: TObject);
|
|
procedure TfmQueryWindow.FindDialog1Find(Sender: TObject);
|
|
begin
|
|
begin
|
|
- fOptions:= [];
|
|
|
|
|
|
+ FOptions:= [];
|
|
|
|
|
|
if frMatchCase in FindDialog1.Options then
|
|
if frMatchCase in FindDialog1.Options then
|
|
- fOptions:= fOptions + [ssoMatchCase];
|
|
|
|
|
|
+ FOptions:= FOptions + [ssoMatchCase];
|
|
|
|
|
|
if frWholeWord in FindDialog1.Options then
|
|
if frWholeWord in FindDialog1.Options then
|
|
- fOptions:= fOptions + [ssoWholeWord];
|
|
|
|
|
|
+ FOptions:= FOptions + [ssoWholeWord];
|
|
|
|
|
|
if not (frDown in FindDialog1.Options) then
|
|
if not (frDown in FindDialog1.Options) then
|
|
- fOptions:= fOptions + [ssoBackwards];
|
|
|
|
|
|
+ FOptions:= FOptions + [ssoBackwards];
|
|
|
|
|
|
if frEntireScope in FindDialog1.Options then
|
|
if frEntireScope in FindDialog1.Options then
|
|
- fOptions:= fOptions + [ssoEntireScope];
|
|
|
|
|
|
+ FOptions:= FOptions + [ssoEntireScope];
|
|
|
|
|
|
- meQuery.SearchReplace(FindDialog1.FindText, '', fOptions);
|
|
|
|
|
|
+ meQuery.SearchReplace(FindDialog1.FindText, '', FOptions);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1694,14 +1694,14 @@ procedure TfmQueryWindow.FormClose(Sender: TObject;
|
|
var CloseAction: TCloseAction);
|
|
var CloseAction: TCloseAction);
|
|
begin
|
|
begin
|
|
// Check if the transaction is active; then commit it
|
|
// Check if the transaction is active; then commit it
|
|
- if fSqlTrans.Active then
|
|
|
|
|
|
+ if FSQLTrans.Active then
|
|
begin
|
|
begin
|
|
- fSqlTrans.CommitRetaining;
|
|
|
|
|
|
+ FSQLTrans.CommitRetaining;
|
|
if OnCommit <> nil then
|
|
if OnCommit <> nil then
|
|
OnCommit(self);
|
|
OnCommit(self);
|
|
OnCommit:= nil;
|
|
OnCommit:= nil;
|
|
end;
|
|
end;
|
|
- IBConnection.Close;
|
|
|
|
|
|
+ FIBConnection.Close;
|
|
CloseAction:= caFree;
|
|
CloseAction:= caFree;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1714,14 +1714,14 @@ begin
|
|
// Do not log to debug server if built as release instead of debug
|
|
// Do not log to debug server if built as release instead of debug
|
|
SetDebuggingEnabled(false);
|
|
SetDebuggingEnabled(false);
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- fQuery:= TStringList.Create;
|
|
|
|
- // Initialize new instance of IBConnection and SQLTransaction
|
|
|
|
- ibConnection:= TIBConnection.Create(nil);
|
|
|
|
|
|
+ FQuery:= TStringList.Create;
|
|
|
|
+ // Initialize new instance of FIBConnection and SQLTransaction
|
|
|
|
+ FIBConnection:= TIBConnection.Create(nil);
|
|
{$IFDEF DEBUG}
|
|
{$IFDEF DEBUG}
|
|
- ibConnection.OnLog:=@GetLogEvent;
|
|
|
|
- ibConnection.LogEvents:=[detCustom,detExecute,detCommit,detRollBack];
|
|
|
|
|
|
+ FIBConnection.OnLog:=@GetLogEvent;
|
|
|
|
+ FIBConnection.LogEvents:=[detCustom,detExecute,detCommit,detRollBack];
|
|
{$ENDIF DEBUG}
|
|
{$ENDIF DEBUG}
|
|
- fSqlTrans:= TSQLTransaction.Create(nil);
|
|
|
|
|
|
+ FSQLTrans:= TSQLTransaction.Create(nil);
|
|
SynCompletion1.ItemList.CommaText:= 'create,table,Select,From,INTEGER,FLOAT';
|
|
SynCompletion1.ItemList.CommaText:= 'create,table,Select,From,INTEGER,FLOAT';
|
|
SortSynCompletion;
|
|
SortSynCompletion;
|
|
end;
|
|
end;
|
|
@@ -1729,9 +1729,9 @@ end;
|
|
procedure TfmQueryWindow.FormDestroy(Sender: TObject);
|
|
procedure TfmQueryWindow.FormDestroy(Sender: TObject);
|
|
begin
|
|
begin
|
|
// Clean up resources to avoid memory leaks
|
|
// Clean up resources to avoid memory leaks
|
|
- fSqlTrans.Free;
|
|
|
|
- IBConnection.Free;
|
|
|
|
- fQuery.Free;
|
|
|
|
|
|
+ FSQLTrans.Free;
|
|
|
|
+ FIBConnection.Free;
|
|
|
|
+ FQuery.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TfmQueryWindow.FormKeyDown(Sender: TObject; var Key: Word;
|
|
procedure TfmQueryWindow.FormKeyDown(Sender: TObject; var Key: Word;
|
|
@@ -2048,7 +2048,7 @@ end;
|
|
|
|
|
|
procedure TfmQueryWindow.lmFindAgainClick(Sender: TObject);
|
|
procedure TfmQueryWindow.lmFindAgainClick(Sender: TObject);
|
|
begin
|
|
begin
|
|
- meQuery.SearchReplace(FindDialog1.FindText, '', fOptions);
|
|
|
|
|
|
+ meQuery.SearchReplace(FindDialog1.FindText, '', FOptions);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -2075,24 +2075,24 @@ var
|
|
begin
|
|
begin
|
|
TabSheet:= nil;
|
|
TabSheet:= nil;
|
|
// Get DataSet's TTabsheet
|
|
// Get DataSet's TTabsheet
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
- if (fResultControls[i] <> nil) and
|
|
|
|
- (DataSet = fResultControls[i]) then
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
|
|
+ if (FResultControls[i] <> nil) and
|
|
|
|
+ (DataSet = FResultControls[i]) then
|
|
begin
|
|
begin
|
|
- TabSheet:= fParentResultControls[i] as TTabSheet;
|
|
|
|
|
|
+ TabSheet:= FParentResultControls[i] as TTabSheet;
|
|
Break;
|
|
Break;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
// Search for status bar inside current query result TabSheet
|
|
// Search for status bar inside current query result TabSheet
|
|
if TabSheet <> nil then
|
|
if TabSheet <> nil then
|
|
- for i:= 0 to High(fResultControls) do
|
|
|
|
- if fResultControls[i] <> nil then
|
|
|
|
- if (fParentResultControls[i] <> nil) and ((fParentResultControls[i] as TTabSheet) = TabSheet)
|
|
|
|
- and (fResultControls[i] is TStatusBar) then
|
|
|
|
|
|
+ for i:= 0 to High(FResultControls) do
|
|
|
|
+ if FResultControls[i] <> nil then
|
|
|
|
+ if (FParentResultControls[i] <> nil) and ((FParentResultControls[i] as TTabSheet) = TabSheet)
|
|
|
|
+ and (FResultControls[i] is TStatusBar) then
|
|
begin
|
|
begin
|
|
// Display current record and number of total records in status bar
|
|
// Display current record and number of total records in status bar
|
|
- (fResultControls[i] as TStatusBar).SimpleText:= IntToStr(DataSet.RecordCount) +
|
|
|
|
|
|
+ (FResultControls[i] as TStatusBar).SimpleText:= IntToStr(DataSet.RecordCount) +
|
|
' records fetched. At record # ' + IntToStr(DataSet.RecNo);
|
|
' records fetched. At record # ' + IntToStr(DataSet.RecNo);
|
|
break;
|
|
break;
|
|
end;
|
|
end;
|
|
@@ -2105,12 +2105,12 @@ end;
|
|
procedure TfmQueryWindow.CallExecuteQuery(aQueryType: TQueryTypes);
|
|
procedure TfmQueryWindow.CallExecuteQuery(aQueryType: TQueryTypes);
|
|
begin
|
|
begin
|
|
// Get query text from memo
|
|
// Get query text from memo
|
|
- if not(GetQuery(fQuery)) then
|
|
|
|
|
|
+ if not(GetQuery(FQuery)) then
|
|
begin
|
|
begin
|
|
ShowMessage('Could not get valid query');
|
|
ShowMessage('Could not get valid query');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- fStartLine:= 0;
|
|
|
|
|
|
+ FStartLine:= 0;
|
|
|
|
|
|
// Disable buttons to prevent query interrupt
|
|
// Disable buttons to prevent query interrupt
|
|
tbRun.Enabled:= False;
|
|
tbRun.Enabled:= False;
|
|
@@ -2119,20 +2119,20 @@ begin
|
|
tbRollback.Enabled:= False;
|
|
tbRollback.Enabled:= False;
|
|
tbRollbackRetaining.Enabled:= False;
|
|
tbRollbackRetaining.Enabled:= False;
|
|
|
|
|
|
- fModifyCount:= 0;
|
|
|
|
|
|
+ FModifyCount:= 0;
|
|
|
|
|
|
// Get initial query type; this can be changed later in the next parts
|
|
// Get initial query type; this can be changed later in the next parts
|
|
if aQueryType = qtUnknown then // Auto
|
|
if aQueryType = qtUnknown then // Auto
|
|
- fOrigQueryType:= GetQueryType(fQuery.Text)
|
|
|
|
|
|
+ FOrigQueryType:= GetQueryType(FQuery.Text)
|
|
else
|
|
else
|
|
- fOrigQueryType:= aQueryType;
|
|
|
|
|
|
+ FOrigQueryType:= aQueryType;
|
|
|
|
|
|
// Call execute query for each part until finished
|
|
// Call execute query for each part until finished
|
|
- fCnt:= 0;
|
|
|
|
- fFinished:= False;
|
|
|
|
|
|
+ FCounter:= 0;
|
|
|
|
+ FFinished:= False;
|
|
repeat
|
|
repeat
|
|
ExecuteQuery;
|
|
ExecuteQuery;
|
|
- until fFinished;
|
|
|
|
|
|
+ until FFinished;
|
|
EnableButtons;
|
|
EnableButtons;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2163,32 +2163,32 @@ end;
|
|
procedure TfmQueryWindow.ThreadTerminated(Sender: TObject);
|
|
procedure TfmQueryWindow.ThreadTerminated(Sender: TObject);
|
|
begin
|
|
begin
|
|
// Raise exception if an error occured during thread execution (Open)
|
|
// Raise exception if an error occured during thread execution (Open)
|
|
- if fQT.Error then
|
|
|
|
|
|
+ if FQT.Error then
|
|
begin
|
|
begin
|
|
- if Assigned(fTab) then
|
|
|
|
- fTab.TabVisible:= False;
|
|
|
|
- SetLength(fResultControls, High(fResultControls));
|
|
|
|
- SetLength(fParentResultControls, High(fParentResultControls));
|
|
|
|
- fTab:= CreateResultTab(qtExecute, fSqlQuery, fSqlScript, fmeResult);
|
|
|
|
- PageControl1.ActivePage:= fTab;
|
|
|
|
-
|
|
|
|
- fmeResult.Text:= fQT.ErrorMsg;
|
|
|
|
- fmeResult.Lines.Add(fQueryPart);
|
|
|
|
- fmeResult.Font.Color:= clRed;
|
|
|
|
- fTab.Font.Color:= clRed;
|
|
|
|
- fTab.ImageIndex:= 3;
|
|
|
|
|
|
+ if Assigned(FTab) then
|
|
|
|
+ FTab.TabVisible:= False;
|
|
|
|
+ SetLength(FResultControls, High(FResultControls));
|
|
|
|
+ SetLength(FParentResultControls, High(FParentResultControls));
|
|
|
|
+ FTab:= CreateResultTab(qtExecute, FSQLQuery, FSQLScript, FResultMemo);
|
|
|
|
+ PageControl1.ActivePage:= FTab;
|
|
|
|
+
|
|
|
|
+ FResultMemo.Text:= FQT.ErrorMsg;
|
|
|
|
+ FResultMemo.Lines.Add(FQueryPart);
|
|
|
|
+ FResultMemo.Font.Color:= clRed;
|
|
|
|
+ FTab.Font.Color:= clRed;
|
|
|
|
+ FTab.ImageIndex:= 3;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- fTab.Caption:= faText;
|
|
|
|
- fTab.ImageIndex:= 0;
|
|
|
|
- fmMain.AddToSQLHistory(RegRec.Title, 'SELECT', fQueryPart);
|
|
|
|
|
|
+ FTab.Caption:= FAText;
|
|
|
|
+ FTab.ImageIndex:= 0;
|
|
|
|
+ fmMain.AddToSQLHistory(FRegRec.Title, 'SELECT', FQueryPart);
|
|
end;
|
|
end;
|
|
- fQT.Free;
|
|
|
|
- if fFinished then
|
|
|
|
|
|
+ FQT.Free;
|
|
|
|
+ if FFinished then
|
|
EnableButtons;
|
|
EnableButtons;
|
|
|
|
|
|
- if not fFinished then
|
|
|
|
|
|
+ if not FFinished then
|
|
ExecuteQuery;
|
|
ExecuteQuery;
|
|
|
|
|
|
end;
|
|
end;
|