Knowledge Base
 

  

 

 

Knowledge Base
Previous  BackToCategory  Next  5 of 47
Use transactions in a process

 

Summary
Requirements
Create a Process
Inserting Process Variables into the Process
Inserting two SQL Command nodes into the process
Inserting an If node into the process
Inserting a Merge node into the process
Inserting two Transaction Operation nodes into the process
Configure the code for the SQL Command nodes
Configure the code for the If node
Connect the nodes
Save the Process
Run the Process

Summary

This article demonstrates how to use Transactions in a Process.

Requirements

  1. Enterprise Enabler version 5.x
  2. Process Designer
  3. BankA.mdb
  4. BankB.mdb

 


Create a Process

Open Enterprise Enabler and create a new process by clicking File » New » Process.




Inserting Process Variables into the Process

In the Toolbox menu go to Proc. Variables, select Proc. Variable and drag it into the process designer area. Rename the Proc. Variable to bankAconsStr. Set the initial value of the variable to the connection string used to connect to the BankA.mdb. Create another variable and rename it bankAResult. Create two more variables for Bank B and name them bankBconsStr and bankBResult. Create another variable and rename it transferAmount.


Inserting two SQL Command nodes into the process

In the Toolbox menu go to Action Nodes, select SQL Command and

drag it into the process designer area. The SQL Commandnode uses two local variables and these need to be mapped to the Process Variables. The mapping

can be done by clicking SQL Command node in the designer and then the ellipsis in VariableMappings property in the Properties window. Follow the same

process to add another SQL Command node. Set ExecuteType as ExecuteNonQuery 

for both the SQL Command nodes.

 

Select the commandResults variable and click the Edit button. Select the bankAResult Process Variable from the following window and click Select button. 

 

Continue mapping the local variable connectionString with the process variable bankAConStr. Repeat the same steps with the second 

SQL Command node using bankBResult and bankBConStr respectively. 


Inserting an If node into the process

In the Toolbox menu go to Condition & Loop Nodes, select If and drag it into the process designer area.

 


Inserting a Merge node into the process

In the Toolbox menu go to Special Nodes, select Merge and drag it into

the process designer area. Set the TypeOfMerge asSimple. 

 


Inserting two Transaction Operation nodes into the process

In the Toolbox menu go to Action Nodes, select Transaction Operation and drag it into the process designer area. Set theOperation as Commit for this node. Follow the same process to add another Transaction Operation node, but set the Operationas Rollback for this node.

 


Configure the code for the SQL Command nodes

Click on the SQL Command node and open the code window by clicking

the ellipsis of SQLStatement property in the Propertieswindow. 

 

Click on the Code Window and enter the following code:

  view plain | print
1 Return "update checkingaccount set balance=( " & _ 
2 " balance +" & ProcessVariable("transferAmount") & " ) where accountnumber='123451'" 



 

Click on the Save button to exit the code. Now click on the second SQL Command node and open the code window by clicking the ellipsis of SQLStatement property in the Properties window. Click on the Code Window and enter the following code:

  view plain | print
1 Return "update checkingaccount set balance= (" & _ 
2 " balance-" &  ProcessVariable("transferAmount")  & ") where accountnumber='123450'" 



 

Click on the Save button to exit the code.


Configure the code for the If node

Click on the If node and open the code window by clicking the ellipsis of Expression property in the Properties Window. Click on theCode Window and

enter the following code:

  view plain | print
1 Return  (ProcessVariable("bankAResult") =1) AndAlso  (ProcessVariable("bankBResult") =1) 

 



 

Click on the Save button to exit the code.

Connect the nodes

In the designer window drag the arrow of the connector from the Start node

and drop it on the SQL Command node. Add aTransition node by dragging it from the Toolbox onto the designer area. Now connect the starting point of the Transition node to the SQL Command node and the ending point (arrow) to the Merge node. Change the Transition Type property of the Transitionnode to EXCEPTION in the Properties window. Drag the arrow of the connector from the SQL Command node and drop it on the second SQL Command node. Add another Transition node by dragging it from the Toolbox onto the designer. Now connect the starting point of the Transition node to the SQL Command node and the ending point to the Merge node. Change the Transition Type property of the Transition node to EXCEPTION in the Properties window. Drag the arrow of the connector from the secondSQL Command node and drop it on the If node. Add another Transition node by dragging it from the Toolbox onto the designer. Now connect the starting point of the Transition node to the If node and the ending

point to the Merge node. Change theTransition Type property of the Transition node to NO in the Properties window. Drag the arrow of the 

If node and drop it on the first Transaction Operation node. Change the 

Transition Type property of the Transition node to YES in the Properties window. Drag the arrow of the connector from the Merge node and drop it on the second Transaction Operation node. Drag the arrows from the both the 

Transaction Operation 

nodes to the Stop node. The completed process should look like the following figure: 

 


Save the Process

Click anywhere in the empty area on the designer window and rename the process name in the Properties window.



To save the process click the Save button in the Standard toolbar. 




Run the Process

Click on the Start the Process button in the Process Designer toolbar to run the process. 

 


Previous  BackToCategory  Next  5 of 47
Copyright © 2010 by Stone Bond Technologies | Phone: +1 (713) 622-8798   |  Privacy Statement   |  Terms of Use