Database Guide

Working with the packeting container details part

The packeting container details part not only provides a convenient way to display data, but also provides a working form that enables the user to edit and update data in the database.

You can add some finishing touches to the window as follows:

Formatting a packeting container details part

For more information on using the packeting container details part refer to the VisualAge Smalltalk User's Guide.

Applying changes to the database

You can also add push buttons to an application for saving or discarding changes that the user makes to the container details part.

  1. Add two push buttons, labeled Apply and Cancel.
  2. Make the following connections for the Apply push button:

    1. Connect its clicked event to the apply action of the result table
    2. Connect its clicked event to the commitTransaction action of the multi-row query
  3. Make the following connections for the Cancel push button:
    1. Connect its clicked event to the cancel action of the result table
    2. Connect its clicked event to the rollbackTransaction action of the multi-row query

    Be certain you make the connections in the order shown.

  4. Select Test to test your visual part.

When you change the rows in the container details part and then apply the changes, VisualAge performs all the SQL statements that are needed to update the rows you changed. Similarly, if you use the newRow or deleteRow actions to insert or delete rows, VisualAge performs the insert and delete SQL statements also. When you use the cancel action instead, VisualAge discards the changes you made.

Tip
The commitTransaction action makes the changes permanent in the database. If your application has more than one query, be certain that you perform all the apply actions for the various queries first, and perform the commitTransaction action last, since it commits all of the work for all of the transactions. Conversely, the rollbackTransaction action discards all the work for all uncommitted transactions.

The commitTransaction and rollbackTransaction actions are executed against a database connection. If your application has more than one database connection, make sure that you commit or rollback against the correct connection.

For the sample application, the update policy set in the Multi-row Query Settings window requires that users specifically commit their changes to the result table. If you edit one cell in the result table and then move on to another cell, you can still rollback your changes to the first cell until you select the Apply push button.

If the update policy for a query uses the Auto commit setting but not the Defer updates setting, then changes to the result table are committed immediately and these push buttons are not required.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]