$InTransaction

$InTransaction

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

$InTransaction

Indicates if an explicit transaction is in progress.

Syntax

$intransaction

Return Value

“1” ($True), or “0” ($False). Can be reset by an application program.

Description

$InTransaction acts as a flag, indicating if the software is currently processing an explicit transaction.

$InTransaction is set to “1” ($True) if a TRANSACTION (or BEGIN WORK) command has started an explicit transaction. It is set to “0” ($False) when an ENDTRANSACTION or QUITTRANSACTION (or COMMIT WORK or ROLLBACK WORK) command has closed the explicit transaction in progress.

The variable is unaffected by deadlock or implicit transactions.

Example

on deadlock
   if $intransaction = $true
      goto RetryAdd
   else
      goto previous
   endif
endon
   ... other commands ...
RetryAdd:
   transaction
   ... commands in the transaction ...
   endtransaction

In the above example, when a deadlock occurs, $InTransaction determines the course of action that the exception handler takes: restart the explicit transaction (when true) or retry the command that caused the deadlock (when false).

procedure UpdateCode (NewCode) local (DoEndTrans)
   if $intransaction = $false
      transaction
      let DoEndTrans = $true
   endif
   ... other commands ...
   if DoEndTrans = $true
      endtransaction
   endif
endprocedure

In the above example, $InTransaction starts an explicit transaction if one is not already in progress.

See Also

BEGIN WORK

COMMIT WORK

GOTO

GOTO NEXT

GOTO PREVIOUS

ON

QUITTRANSACTION

ROLLBACK WORK

System Variables

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish