Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
abak
Posts: 25
Joined: Sat 18 Oct 2014 18:42

Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Post by abak » Mon 08 Oct 2018 10:23

Hello Devart Team,
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;
Thx.

ViktorV
Devart Team
Posts: 2580
Joined: Wed 30 Jul 2014 07:16

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Post by ViktorV » Wed 10 Oct 2018 07:14

Yes, you can easily create TIBCQuery and TIBCSQL instances at runtime and set them to an already running global transaction.

abak
Posts: 25
Joined: Sat 18 Oct 2014 18:42

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Post by abak » Wed 10 Oct 2018 13:27

Good to hear that.
Thx

ViktorV
Devart Team
Posts: 2580
Joined: Wed 30 Jul 2014 07:16

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Post by ViktorV » Wed 10 Oct 2018 13:45

Thank you for the interest to our product.
Feel free to contact us if you have any further questions about our products.

Post Reply