Recent

Author Topic: IBX IBTransaction  (Read 331 times)

sydenis

  • New Member
  • *
  • Posts: 37
IBX IBTransaction
« on: October 04, 2024, 10:14:44 am »
Please tell me about IBTransaction - what is the difference between:

1. Active := true  and  StartTransaction
2. Active and InTransaction

rvk

  • Hero Member
  • *****
  • Posts: 6497
Re: IBX IBTransaction
« Reply #1 on: October 04, 2024, 11:37:21 am »
1. TIBTransaction.Active := true will rollback a possible current running transaction and start a new one.
TIBTransaction.StartTransaction will give you an exception if the transaction is already running.

Code: Pascal  [Select][+][-]
  1. procedure TIBTransaction.SetActive(Value: Boolean);
  2. begin
  3.   if csReading in ComponentState then
  4.     FStreamedActive := Value
  5.   else
  6.     if Value and not InTransaction then
  7.       StartTransaction
  8.     else
  9.       if not Value and InTransaction then
  10.         Rollback;
  11. end;

2. Reading the properties TIBTransaction.Active and TIBTransaction.InTransaction are the same

Code: Pascal  [Select][+][-]
  1.  
  2. public
  3.   property InTransaction: Boolean read GetInTransaction;
  4. published
  5.   property Active: Boolean read GetInTransaction write SetActive;

sydenis

  • New Member
  • *
  • Posts: 37
Re: IBX IBTransaction
« Reply #2 on: October 04, 2024, 11:45:42 am »
Thank you. It became clear!

tonyw

  • Sr. Member
  • ****
  • Posts: 325
    • MWA Software
Re: IBX IBTransaction
« Reply #3 on: October 08, 2024, 05:01:29 pm »
1. TIBTransaction.Active := true will rollback a possible current running transaction and start a new one.
Not quite true. Setting an active transaction to false will rollback the current transaction. Setting an active transaction to true is a no op

rvk

  • Hero Member
  • *****
  • Posts: 6497
Re: IBX IBTransaction
« Reply #4 on: October 08, 2024, 05:06:09 pm »
1. TIBTransaction.Active := true will rollback a possible current running transaction and start a new one.
Not quite true. Setting an active transaction to false will rollback the current transaction. Setting an active transaction to true is a no op
That's why I said "possible current running transaction". If there is no current transaction, rollback is of course not possible  ;)

 

TinyPortal © 2005-2018