Difference between StartTransaction and Active:= True; lazarus / 16-Databases ---------------------------------------------------------------------- egsuh · 2020-04-27 09:08 Hi, I used to use  syntax as following, because this was the way Delphi books explained.    if not SQLTransaction1.Active then SQLTransaction1.StartTransaction; But I'm just curious following statement does what the previous one does.     SQLTransaction1.Active := True; Does this start a new transaction if the transaction was not active , and do nothing if it was active? ---------------------------------------------------------------------- eljo · 2020-04-27 09:24 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDBTransaction.SetActive(Value : boolean);begin  if FActive and (not Value) then    EndTransaction  else if (not FActive) and Value then  if csLoading in ComponentState then // if the properties are not finished loading yet      begin      FOpenAfterRead := true; // call start transaction at a later time.      exit;      end    else       StartTransaction; end; So as you can see setting active true at runtime will call startTransaction so yeah its the same. ---------------------------------------------------------------------- rvk · 2020-04-27 09:29 Quote from: eljo on April 27, 2020, 11:24:46 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDBTransaction.SetActive(Value : boolean);begin  if FActive and (not Value) then    EndTransaction  else if (not FActive) and Value then  if csLoading in ComponentState then // if the properties are not finished loading yet      begin      FOpenAfterRead := true; // call start transaction at a later time.      exit;      end    else       StartTransaction; end; So as you can see setting active true at runtime will call startTransaction so yeah its the same. You missed something in the code  You see a "not FActive" in the second if. So setting Active to true will ONLY call starttransaction if the transaction isn't already started. That's different from just calling starttransaction. ---------------------------------------------------------------------- eljo · 2020-04-27 09:31 Nope you missed the code compared to and I quote. Quote from: egsuh on April 27, 2020, 11:08:46 amI used to use  syntax as following, because this was the way Delphi books explained. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    if not SQLTransaction1.Active then SQLTransaction1.StartTransaction; So yes setting active to true is equivalent with the code above. ---------------------------------------------------------------------- egsuh · 2020-04-27 09:34 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if csLoading in ComponentState then // if the properties are not finished loading yet      begin      FOpenAfterRead := true; // call start transaction at a later time.      exit;      end I'm not sure about the above codes, but except that it seems to act as I want. For example,    Transaction.Active := True;   // Starts transaction if not active, and do nothing if already active    Transaction.Active := False;   // Closes transaction if active, possibly using default action Many thanks to you guys for kind comments. ---------------------------------------------------------------------- eljo · 2020-04-27 09:38 Quote from: egsuh on April 27, 2020, 11:34:56 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if csLoading in ComponentState then // if the properties are not finished loading yet      begin      FOpenAfterRead := true; // call start transaction at a later time.      exit;      end I'm not sure about the above codes, but except that it seems to act as I want. For example,    Transaction.Active := True;   // Starts transaction if not active, and do nothing if already active    Transaction.Active := False;   // Closes transaction if active, possibly using default action Your assumption is correct it uses the default Action to determinate what to do when endtransaction is called. ---------------------------------------------------------------------- rvk · 2020-04-27 09:48 Quote from: eljo on April 27, 2020, 11:31:57 amNope you missed the code compared to and I quote. Quote from: egsuh on April 27, 2020, 11:08:46 amI used to use  syntax as following, because this was the way Delphi books explained. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    if not SQLTransaction1.Active then SQLTransaction1.StartTransaction; So yes setting active to true is equivalent with the code above. Ah, Ok, Sorry. I only reacted to your statement (especially the words marked in bold): Quote from: eljo on April 27, 2020, 11:24:46 amSo as you can see setting active true at runtime will call startTransaction so yeah its the same. Didn't realize you responded to the snippet gives.