Salesforce

What About Multi-User Environments (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

What About Multi-User Environments? (Magic xpa 4.x)

When developing an application for a multi-user situation, in which it is possible that two users will access the same data at the same time, the necessity of developing with transactions is increased.

You can activate transaction processing at any of the task execution levels by setting the Transaction Mode and Transaction Begin properties in the Data tab of the Task Properties dialog box.

Let us look at this with the same simple scenario. Let us assume that Fred wants to transfer the last $50 from his Savings account to his Checking account (sound familiar?). But, his wife Wilma is currently at another branch of the bank and is withdrawing $50 from the Checking account in order to purchase the weekly groceries.

What can happen? In this case, the scenario is not as simple as it may seem:

Fred

Wilma

Read Savings amount

Savings = Savings – 50

Read Checking amount

Checking = Checking + 50

Read Checking amount

At the same time that Wilma is checking the current balance of the Checking account, in order to withdraw the cash, Fred is putting the money in. In this case, she will probably see that the money has not yet gone through. She will then check the balance of the Savings account and what will she see? It is empty (remember we mentioned that Fred is withdrawing the last $50). The result will now be angry conversations between the happy couple.

In the world of transactions, this scenario would be slightly different. When the process is executed as a single logical unit, a useful by-product of this is that any updated data is locked until the transaction has completed. In this case, Wilma will still probably see that the money has not yet gone through, but when she then checks the balance of the Savings account, she will see that there still is money in that account. The telephone call to Fred will take on a different tone.

It should be pointed out that the locks are accumulative within the transaction. For example, after updating a certain record (which is locked as a result), the user updates a second record. Both of these records are part of the transaction and will be locked until the transaction is either committed or rolled back.

The Rollback function can be used to roll back a transaction to a specified nesting level, or to abort the transaction completely. The Rollback function receives as a parameter the number of nesting levels for the rollback point. The parameter number must be a number of open nested transactions. A parameter value of zero will roll back the entire transaction to the first level. After forcing a rollback, Magic xpa resumes processing according to the rollback level defined in the Error behavior strategy property.

The Rollback function lets you display a confirmation dialog box to the end-user before the actual rollback operation starts.

Supposing Wilma decides that instead of phoning Fred, she is going to transfer the money herself. But by the time this happens, the transaction with Fred has been completed (committed). Now, in this case, when she tries to check the current balance of the Savings account, the amount has already been updated. She can now happily withdraw the money from the Checking account.

What actually happens in this particular case really depends on the DBMS used, but the purpose here is to give a simple overview of transactions.

Reference
Attachment 
Attachment