Home
Reply
Regular Contributor
Posts: 58
0
Accepted Solution

API_BEGIN/END rollback

There are many discussions on API_BEGIN/END usage, but I'm still confused...

I was under impression that the following code would rollback the possible changes if success==false:

 

API_BEGIN

 

...some entities changed here...

 

if ( !success )
   result = outcome(API_FAILED);

 

API_END

 

I was wrong of course: rollback happens only in outermost API_BEGIN/END block if the bad result is propagated.

 

Hence the question: how can I make sure that possible unwanted changes will be rollbacked? I can't use API_NOP_BEGIN/END since I need to rollback only in some cases, when something went wrong. 

Even if the code above works as intended (rollbacks after failure),  up-level changes can break it if API_BEGIN/END block will be added into a calling method.

Will option bb_immediate_close help in this case?

 

Thank you!

Spatial Employee
Posts: 151
0

Re: API_BEGIN/END rollback

Hi YT

 

API_TRIAL_BEGIN/API_TRIAL_END works the way you want (rolls on failure even when nested).  That is not the default behavior of API_BEGIN/API_END because it is a performance optimization not to need extra bulletin boards.

 

cheers

 

Eric

Regular Contributor
Posts: 58
0

Re: API_BEGIN/END rollback

Wow, you are really fast and I'm really stupid :)

Thanks again!