cancel
Showing results for 
Search instead for 
Did you mean: 

How test if a call of a transaction fails inside another transaction

Former Member
0 Kudos

Hi there,

I have two transactions: T1 and T2. T1 calls T2. T2 have a "SQL" action.

When I disable the data server used for that SQL action my sql command fails. Thats okay. So a have a "Conditional" action testing the parameter "sucess" of that SQL action and when it is "false" a "Terminate transatcion" action is used. The links are:

Terminate_Transaction.TerminateWithError = sql_nameOfQuery.Success

Terminate_Transaction.TerminationMessage = sql_nameOfQuery.Results{/Rowsets/FatalError}

Using a "Trace" action in T2 I can see that:

sql_nameOfQuery.Success = false

sql_nameOfQuery.Results{/Rowsets/FatalError} = "Server Test is currently disabled"

My problem is how T1 kowns that T2 was terminated with a fail. I put a "conditional" action with the link:

Conditional.Output = not( T2.Success )

and it is not working for me. Is this link right for the Conditional action?

Despite de fact it call a "Terminate transaction" action I have always "OK" value for T2.Sucess!

Using a "Trace" action in T1 I can see that:

T2.Sucess = OK

T2LastErrorMessage = TRANSACTION EXECUTED OK

Thank in advance,

Nuno Cunha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Nuno,

in your T2, you can populate the TerminationMessage with your Error Text from the query.

In T1, you will receive the error message in T2.LastErrorMessage. If you set the TerminateWithError Flag in T2, you can evaluate the T2.Success flag in T1 which will then be false. If you do not set the TerminateWithError in T2, the T2.Success Flag will be true, however the LastErrorMessage will still be set.

The text "TRANSACTION EXECUTED OK" in T2.LastErrorMessage will appear if the Transaction (T2) was not terminated.

Michael

Former Member
0 Kudos

Hi Otto,

I did what you wrote, I think. There is an error at some link...

The "Conditional" action after the SQL Action links:

Conditional.Output = not( sql_nameOfQuery.Success)

Is it right?

My conditional has no "false" brach of actions because it is in the end of transaction T2.

If conditional is "true" (so there was an error in executing the SQL action) I have a Trace (only to see if we are at the "true" branch) and a "Terminate transaction", with the links I put on the first message.

With the data server disabled I can't see the output of the trace inside de "true" branch!.

What could be wrong in my conditional?

thank you

Former Member
0 Kudos

Hi,

as Input1 to the Conditional, use "! sql_nameOfQuery.Success". This should work.

Michael

Former Member
0 Kudos

Hi otto,

Great! This was one of my mistakes! I did not know about "!". I saw "not(boolean)" in the select box then I thought it was the correct one.

This is the last action of T2.

-

-


Let explore you a litte more...

In T1 I have a General conditional where I have tree children braches. One for "true", one for "false" and other to be execute after, as showed below:

if true: - - - - (branch true)

if false: - - - - (branch false)

- (do after true or false)

My problem now is that after be terminated (in my case without sucess) I use for testing and stop my transaction .

Conditional1a.Input1 = ! T2.Success

I was expecting and not to be executed, but it is!

: Execution Started At: 14:40:18

: Execution Started At: 14:40:18

: Server Localizar is currently disabled

: ACTION FAILED: End Action sql_AtualizarTrator : (SQL Query)

: Falhou ao executar atualização: Server Localizar is currently disabled (trace inside T2)

: Execution Completed At: 14:40:18 Elapsed Time was 30 mS

: Sucess -LastErrorMessage: 1 - Server Localizar is currently disabled (trace I put just before Conditional1a)

: Server Localizar is currently disabled

: ACTION FAILED: End Action sql_Action_Z : (SQL Query) (not shoud be executed!)

: Server Localizar is currently disabled

: ACTION FAILED: End Action sql_log : (SQL Query) (not shoud be executed!)

: Execution Completed At: 14:40:18 Elapsed Time was 100 mS

Why T2.Sucess is 1 if I did the following link at T2

Terminate_Transaction.TerminateWithError = sql_nameOfQuery.Success

Terminate_Transaction.TerminationMessage = sql_nameOfQuery.Results{/Rowsets/FatalError}

The error message is OK, but the boolean not. How to do this conditional? Creating another transaction parameter only to be used at my ?

Nuno Cunha

Former Member
0 Kudos

Hi,

you assume the following:

Terminate_Transaction.TerminateWithError = sql_nameOfQuery.Success is true. Did you want to write

Terminate_Transaction.TerminateWithError = ( ! sql_nameOfQuery.Success ) ?

I suggest some assignment to Terminate_Transaction.TerminateWithError like

stringif( sql_nameOfQuery.Results{/Rowsets/FatalError} != "", 1, 0 )

This will set the TerminateWithError flag.

Give it a try.

Michael

Former Member
0 Kudos

Hi,

Great. Finally the transaction T1 stop where I want.

Very strange the value "true" for sql_nameOfQuery.Success even when data server is disable!

Otto, thank you very much.

Nuno

Answers (0)