Step 4: Writing Transactions to the Data Source

In this section:

Goal

Now that the customer information has been edited, you must write the updated information to the data source. You do this using the UPDATE and COMMIT commands.


Top of page

x
Methods: Write Commands, COMMIT, and ROLLBACK

To make changes to a data source, you issue the write commands: INCLUDE, UPDATE, REVISE, or DELETE. These perform the same functions as the MODIFY commands of the same names. In Maintain, however, these commands are enhanced so that you can perform a transaction for:

These phrases were described for other commands in Step 2: Selecting Records and Step 3: Collecting Transaction Values.

To guarantee the integrity of all the include, update, and delete operations comprising a single logical transaction, you code a COMMIT command immediately following the last step of the transaction. Then, if a system problem or another application interrupts the logical transaction, it is rolled back—that is, cleared—without being written to the data source. In this way, you can guarantee that no transaction component is ever written to the data source unless all transaction components are—that is, unless it is part of a complete and successful logical transaction.


Top of page

x
Solution

You add an UPDATE command to update the data source. Each part of the command plays a different role:

You define the entire procedure as one logical transaction and issue a COMMIT command to send the changes to the data source. The first stage of the procedure is now finished and looks like this:

MAINTAIN FILE VIDEOTRK
FOR ALL NEXT CustID INTO CustInfo
WHERE ExpDate GE 920601 AND ExpDate LE 920621;
WINFORM SHOW ShowCust; 
FOR ALL UPDATE LastName FirstName Street City State Zip
Phone FROM CustInfo;
COMMIT; 
-* >> Generated Code Section....
.
.
.
END

Try it now: If you have created your own set of application files, enter these additional commands into your Maintain procedure file.


Information Builders