Basic Incremental Update Mechanism:
We will illustrate the essence of the Incremental Update mechanism through a simple example.
Example 1: Simple ‘Running Total’.
In this example we will simply accumulate a ‘Running Total’ for list of numerical values entered and maintained by a user in an online task.
Let’s consider the following table with two columns:
Table: List_of_Values
Columns:
1) Code: Alpha (2)
2) Value: Numeric (5)
Provided the table is empty at the time of executing the process described hereafter.
Lets describe a process that allows basic maintenance with regular Creation, Modification and Deletion capabilities at row level during an Online, Line mode session.
In addition to the above, the process must maintain and display an accurate and up to date ‘Running Total’ of all the values entered during the online session.
Logical Considerations:
Before describing how the above running total can be maintained in an eDeveloper task, lets describe the procedural details required to achieve such result:
1) Upon creating a new line (Create mode), the value entered on the new row must be added to the ‘Running Total’ accumulator.
Example:
- Creating a first line in the table with a value of a hundred (100) results in adding this value to the originally (0) ‘Running Total’ value. The result is Running Total = 0 + 100 = 100.
- Creating a Second line in the same table with a value of a fifty (50) results in adding this value to the actual (100) ‘Running Total’ value. The result is Running Total = 100 + 50 = 150.
- Creating a third line in the same table with a value of a twenty (20) results in adding this value to the actual (150) ‘Running Total’ value. The result is Running Total = 150+ 20 = 170.
2) Upon deleting a line, the value that was on this line (prior to its deletion) must be subtracted from the ‘Running Total’ accumulator.
Example:
Deleting the second line (value of 50) of our ongoing example, results in subtracting this value from the actual (170) ‘Running Total’ value. The result is Running Total = 170 – 50 = 120.
3) Upon modifying the value on an existing line, the Net Difference of the modification must be applied to the ‘Running Total’ accumulator. The Net Difference can be described further as:
Net Difference = Final Value – Original Value
For Example:
- Coming back on the line with (20) as the value, modifying this value to make it (30), results in applying the Net Difference (30 - 20=10) to the actual (120) ‘Running Total’ value.
The result is: Running Total = 120 + (30-20) = 120 + 10 = 130
Notice that the Net Difference can be negative if a Value is modified as such that the Final Value is less than the original Value.
- Coming back on the first line with (100) as the value, modifying this value to make it (60), results in applying the Net Difference (60 - 100= -40) to the actual (130) ‘Running Total’ value.
The result is: Running Total = 130 + (60-100) = 130 - 40 = 90
Comments and observations:
1) The above sequence is quite simple to predict, However, it does reveal that even a simple ‘Running Total’ accumulation process must take care of a several scenarios and adjust its execution accordingly in order to guaranty an accurate result.
2) If we list what is required to be known at each accumulation step in order to perform the right calculations, we get:
- The Current Mode of execution (Create, Modify or Delete).
- The Original value of the ‘Value’ field.
- The Final value of the ‘Value’ field.
3) The items of the above list are all items that the eDeveloper engine knows and keeps track of at all time. The Stat() and the Varprev() functions are evidence of such fact.
4) Therefore, it is correct to conclude that the eDeveloper engine knows and is already maintaining everything that is necessary to be able to handle complete and accurate accumulation (“Incremental”) processing.
eDeveloper is not only able to process “Incremental” logic, It actually does it all for us provided we instruct it to:
- Do ‘Incremental’ logic rather than just doing direct assignation of a value.
- Refer to what needs to be accumulated. In our case the ‘Value’ column is what must be accumulated into the ‘Running Total’.
Update, How = Incremental:
We will now describe how simple it is to add to an eDeveloper task what would support the above-described example.
First create a simple program that provides regular line mode access and maintenance to the List_of_Values table. This can be done through the following steps:
1) Create the previously described memory table with the two columns mentioned (Code and Value)
2) Generate a new program on the above table:
- Browse Online
- Line mode
- With the two columns selected.
To add the ‘Running Total’ and associated processing logic, we do the following:
1) Add the following:
- Data View (Record Main): Add a virtual Column: Running Total, Numeric (7).
- In the form editor: Add a control on the form bound to the new ‘Running Total’ variable.
2) In the Record Suffix add the following operation:
Update, Running Total, Exp=Value, How=Incr
The ‘How=Incr’ parameter is what will trigger the engine to perform ‘Incremental’ accumulation rather that direct assignation logic. The expression referring to the ‘Value’ column informs the engine of the seed (detailed subject) of the accumulation. This will vary from one process to the other and is the responsibility of the developer to properly identify and specify. But the engine automatically and accurately performs everything else.
3) Run the program and see how the running total is properly maintained and displayed as the user enters and modify information on the screen.
Back To:
Incremental Update
The original version of this page was provided by: InformaPlus
There are no comments on this page. [Add comment]