Programming Guide



SAVE

Saves the changes made on the screen to the database

int sm_tm_command ("SAVE [ tableViewName [ tableViewScope ] ]");

Arguments

tableViewName
The name of a table view in the current transaction. This parameter is case sensitive.
If tableViewName is specified, the command is applied according to the tableViewScope parameter. Since the entire table view tree might not be included, this is known as a partial command, and sm_tm_command sets TM_FULL to 0. Refer to the description for more information about partial commands.
If tableViewName is not specified, the command is applied for each table/server view, starting with the root table view. This is known as a full command, and sm_tm_command sets TM_FULL to 1.

tableViewScope
One of the following parameters, which must be preceded by a table view name.

Description

SAVE compares the current screen to the before image data and generates the necessary statements needed to update the database.

After you select SAVE, the following steps occur:

  1. The transaction manager checks to see that the mode is not initial or view.
  2. For engines requiring it, the transaction model starts a database transaction.
  3. The transaction model calls the SQL generator to execute the necessary statements according to the changes that were entered on the screen. Statements can only be generated for updatable table views.

    Note: Some database engines discard the select set when a commit or rollback is performed. For those engines, the distributed transaction models give up the select cursor after a commit or rollback.

  4. If an error is encountered, the database transaction is rolled back. If no errors are reported and the SAVE command has been specified as a full command, the transaction model commits the database transaction.

Push buttons and menu selections for the SAVE command can choose to set the class property to save_button. By default, save_button is active in new and update modes.

Primary Key Changes

The transaction manager is aware of any primary key changes. If the primary key is updated, the common transaction model deletes the row containing the old value of the primary key and inserts a row contains the new value of the primary key. If the primary key is cleared, the common transaction model deletes the row corresponding to the cleared key fields.

Partial Commands

When a table view is specified for a command, the transaction manager considers it to be a partial command since the command may not apply to the entire tree. In the standard transaction models, the processing for partial SAVE commands does not commit the database transaction. Therefore, you must perform an explicit DBMS COMMIT. Otherwise, the changes could be rolled back if a later rollback is performed or if the database engine automatically performs a rollback when the connection is closed.

Events

The following request events can be generated by the SAVE command: