Welcome Guest! Log in
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.


Using transactions in SQL is very usefull. Having the possibility to rollback in case an error occured is really interesting.

It is possible to use transactions easily in Stambia, with the SQL Operation process action.

This articles shows an example of how to do this in a process.

 

The SQL Operation Action

The use of transactions with SQL Operations is done through specific parameters.

The most commons are:

SQL Transaction Type

Used to indicate the type of the transaction.

Available types: COMMIT,NOCOMMIT,AUTOCOMMIT,AUTONOMOUS

SQL Transaction Name Name of the transaction

 

To do multiple operations using the same transaction, the same SQL Transaction Name has to be put on each of the actions.

By default the actions have AUTOCOMMIT type. More informations on the types can be found in the Designer's help.

 

Example

Here is a little example in which we want to do some operations, and rollback everything if an error occured, or commit otherwise.

Process overview:

Overview

 

All the actions are on same transaction: T1 .

The three first one's are using NOCOMMIT Transaction Type.

The last one uses the COMMIT type, in order to send a commit after the action.

 

With this settings, all the actions will be executed within the same JDBC Connection without doing any commit, except the last one.

So, if everything worked during the process, the last action is executed and the commit done.

But if an error occured, the process will end with errors and stop, the Commit action will then not be executed, so no commit will be performed.

In case of a process ending with errors, the runtime is doing autmatically a rollback. As all the other actions here have NOCOMMIT type, the last commit on which the rollback will be done is before the execution.

 

Example of execution:

error

 

Here one of the actions failed. A rollback will be executed, and the operations performed by the two successfull one's will not be saved.

You have no rights to post comments

Articles

Suggest a new Article!