Insert your own code into CATCH part of 'atomic transaction'

Related products: Software Factory

For a while now, there is a checkbox that lets your code run in an atomic transaction. This is a great improvement allowing you to easily let your code run inside a transaction.

I would like to propose an additional improvement, by letting the user put in a template within the catch-part of the atomic transaction. This way, you can add your own error handling in the catch part of the code as well.

Below an example of what this could look like:

CREATE or ALTER procedure demo
as
begin

--PART 1 of default transaction code, generated by default by Software Factory
begin try
begin transaction;

--Force an error
select 1/0;

--PART 2 of default transaction code, generated by default by Software Factory
commit transaction;
end try
begin catch

if @@trancount > 0
begin
rollback transaction;
end;

--USER ENTERED additional error handling
--for example, writing some error in a log.
insert into error_log (error_log_message)
values ('something went wrong');


--PART 3 of default transaction code, generated by default by Software Factory
throw;
end catch;

end

 

Updated idea status NewOpen
Updated idea status OpenOn the backlog
Updated idea status On the backlogWorking on it!
Updated idea status Working on it!Next release

Hi everyone,

With the upcoming 2021.3 version of the Thinkwise platform it will be possible to weave templates into the catch part of atomic Tasks. The catch part has been separated into two templates and order no. range 99000 - 99998 has been made available for weaving in code.


Hi @Mark Jongeling ,

Thanks for the update.
Question: Is it also possible within the 2021.3 to weave code before the begin try and begin tran?
And also, I some projects I need to have code AFTER the end catch, could that be something to take in consideration for the 2021.3?

Thanks in advance.


Hey @Robbert van Tongeren,

That could have been an addition to this idea, but currently we do no have the time to implement this in the 2021.3 version. Could you post a new idea for this? Then we can monitor the number of votes and see how many others would like this to be part of the Software Factory. Thanks!


This should be an easy fix. Just leave some numbers available to put code after create procedure part and before the ‘end-procedure’ part. Comon.


New idear is created: 

 

I have to say, I agree with @Robert Jan de Nie , weave the first code into place 5 and the last code at 99995 and we are done.. :)


Updated idea statusNext releaseCompleted