Commit Transaction Action - When is it needed, Why?

Commit Transaction Action - When is it needed, Why?

  

Hi All,

When is Commit Transaction (System Action) needed and why?
I have seen this logic being used in some examples but I don't fully understand its purpose, surely if we run a CreateOrUpdate action this commit is not necessary after, why would it not perform this already as a standard?

Thanks,
Andre

André P wrote:

Hi All,

When is Commit Transaction (System Action) needed and why?
I have seen this logic being used in some examples but I don't fully understand its purpose, surely if we run a CreateOrUpdate action this commit is not necessary after, why would it not perform this already as a standard?

Thanks,
Andre

Hi Andre,

Please read below article so you can understand why we can used commit transaction after create or createOrUpdate action into database.

https://success.outsystems.com/Documentation/10/Reference/Data/Database_Reference/Handling_Transactions

As my understanding mostly used commit transaction in Advance Query (insert or update)

Hope this helps!!!

BR,

AV

Hi Andre ,

When there is any error occurred in flow Outsystems roll backs all the transitions previously done in the same flow , in some cases if you want some specific data to be saved in database irrespective of error in the flow you can use commit transition.

This is basically a explicit way of committing the transaction in database at any point.



Regards

-PJ-


Hi André,

Imagine an example where you want to read an excel with 10 records. You will have a cycle where you want to read record by record. If an error occurs reading the 6th record, a rollback will be done and you will lose all the transactions related with the first 5 records. CommitTransaction could be used in order to commit the transaction in the end of reading each record. 

Hope it helps.

Regards,

Miguel Pinto

Another use case when you call webservices. Whenever you call a webservice method, the platform will do it within a DB session / transaction. But a webservice call normally is a very tricky piece of logic, an it can lead your application to errors or keep your transaction open for a long time. In order to free this transaction up, it's a good practice to Commit it just after you receive your webservice call's response.

So I guess we should always have a commit action after a CreateorUpdate, except when we have a long string of logic where we if anything fails we don't want any transactions to be processed (or only commit those transactions that we want).

Is this right?

 Thanks all for clarifications this is useful.

Solution

You won't need to explicitly Commit in most scenarios. Have in mind the the End node will implicitly do it for you.

Using CommitTransaction action is indeed an exception action, and should be used as such, only when explicilty needed.

Solution

Understood. Thanks again Joao and all others that helped to shine light into this.

Hello 

Only to make it clear.


If in a action flow we have 2 update (2 diferent entities) action follow an end node. In terms of rollback what happen if occurs an exception in the second update action. Both action are rollbacked? only the second?

and what if the action occurs in the same entity?


TIA

Hi Alberto,

Yes, in that scenario, both update actions will be rollbacked. Of course, when the exception occurs you can always configured it if you want to abort the transaction or not, like you can see below.

However, imagine if you have a commit between the first and second update. Then only the second update will be rollbacked!

Hope that is clear.


Best Regards,

Miguel Pinto

Thanks Miguel. You make it clear ! :)

João Melo wrote:

You won't need to explicitly Commit in most scenarios. Have in mind the the End node will implicitly do it for you.

Using CommitTransaction action is indeed an exception action, and should be used as such, only when explicilty needed.

Hi, if i implement a parent server action that calls upon a child server action which implements a commit, are transactions done by the parent committed when the child transaction calls a commit?



Caulibeam wrote:

João Melo wrote:

You won't need to explicitly Commit in most scenarios. Have in mind the the End node will implicitly do it for you.

Using CommitTransaction action is indeed an exception action, and should be used as such, only when explicilty needed.

Hi, if i implement a parent server action that calls upon a child server action which implements a commit, are transactions done by the parent committed when the child transaction calls a commit?



Yes