Lesson 1: Creating a dirty read

Create a dirty read, in which the Accountant makes a calculation while the Sales Manager is in the process of updating a price.
The Accountant's calculation uses erroneous information which the Sales Manager enters and is in the process of fixing.

The Sales Manager observes immediately that 0.95 should have been entered instead of 95, but before the error can be fixed,
the Accountant accesses the database from another office.

The company's Accountant is worried that too much money is tied up in inventory. As the Accountant, execute the following
statement to calculate the total retail value of all the merchandise in stock:

SELECT SUM( Quantity * UnitPrice )
AS Inventory
FROM GROUPO.Products;

The following result is returned:

Inventory

21453.00

Unfortunately, this calculation is not accurate. The Sales Manager accidentally raised the price of the tee shirt by $95,
and the result reflects this erroneous price. This mistake demonstrates one typical type of inconsistency known as a dirty read. As the Accountant, you accessed data that the Sales Manager has entered, but has not yet committed.

As the Sales Manager, fix the error by rolling back your first change and entering the correct UPDATE statement. Check that
your new values are correct.

The Accountant does not know that the amount he calculated was in error. You can see the correct value by executing the SELECT
statement again in the Accountant's window.

SELECT SUM( Quantity * UnitPrice )
AS Inventory
FROM GROUPO.Products;

Inventory

6687.15

Finish the transaction in the Sales Manager's window. The Sales Manager would enter a COMMIT statement to make the changes
permanent, but you should execute a ROLLBACK statement instead, to avoid changing the local copy of the SQL Anywhere sample
database.

ROLLBACK;

Results

The Accountant unknowingly receives erroneous information from the database because the database server is processing the
work of both the Sales Manager and the Accountant concurrently.