Skip to main content
Completed

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

Related products:Software Factory
Freddy
rbiram
  • Freddy
    Freddy
  • rbiram
    rbiram

Robert Jan de Nie
Thinkwise blogger

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

 

Did this topic help you find an answer to your question?

10 replies

Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
Updated idea status NewOpen

Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
Updated idea status OpenOn the backlog

Mark Jongeling
Administrator
Forum|alt.badge.img+23
Updated idea status On the backlogWorking on it!

Mark Jongeling
Administrator
Forum|alt.badge.img+23
Updated idea status Working on it!Next release

Mark Jongeling
Administrator
Forum|alt.badge.img+23

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.


Robbert van Tongeren
Thinkwise blogger

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.


Mark Jongeling
Administrator
Forum|alt.badge.img+23

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!


Robert Jan de Nie
Thinkwise blogger
Forum|alt.badge.img+5

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.


Robbert van Tongeren
Thinkwise blogger

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.. :)


Jeroen van den Belt
Administrator
Forum|alt.badge.img+9
Updated idea statusNext releaseCompleted

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings