I have no problem. Just to confirm :
Is it safe to Create at runtime, IBCQuery and IBCSQL after Starting Global Transaction
and attached them to that Transaction ?
Code: Select all
procedure TUniMainModule.DoingSomeThing;
begin
if not IBCTransaction1.Active then IBCTransaction1.StartTransaction;
try
//*****************************************
Operation_1; // Select Statment...
Operation_2; // Update Statment...
//*****************************************
if IBCTransaction1.Active then IBCTransaction1.Commit;
Except
if IBCTransaction1.Active then IBCTransaction1.RollBack;
end;
end;
procedure TUniMainModule.Operation_1;
var Query_Select:TIBCQuery;
txtSQL:string;
begin
Query_Select:=TIBCQuery.Create(Self);
try
Query_Select.Connection:=IBCConnection1;
Query_Select.Transaction:=IBCTransaction1; // My Global Transaction
//===============================================
txtSQL:='Select ... From ...';
// retreiving somme data
//===============================================
finally
Query_Select.Free;
end;
end;
procedure TUniMainModule.Operation_2;
var Query_Upd:TIBCSQL;
txtSQL:string;
begin
Query_Upd:=TIBCSQL.Create(Self);
try
Query_Upd.Connection:=IBCConnection1;
//*************************************
Query_Upd.Transaction:=IBCTransaction1; // The same Global Transaction !
//*************************************
Query_Upd.AutoCommit:=False;
Query_Upd.SQL.Clear;
txtSQL:='Update .....';
Query_Upd.SQL.Add(txtSQL);
Query_Upd.Execute;
finally
Query_Upd.Free;
end;
end;