Page 1 of 1

Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Posted: Mon 08 Oct 2018 10:23
by abak
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.

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Posted: Wed 10 Oct 2018 07:14
by ViktorV
Yes, you can easily create TIBCQuery and TIBCSQL instances at runtime and set them to an already running global transaction.

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Posted: Wed 10 Oct 2018 13:27
by abak
Good to hear that.
Thx

Re: Creating IBCQuery and IBCSQL after Starting Global Transaction ?

Posted: Wed 10 Oct 2018 13:45
by ViktorV
Thank you for the interest to our product.
Feel free to contact us if you have any further questions about our products.