Programming Guide |
Saves the changes made on the screen to the database
int sm_tm_command ("SAVE [tableViewName
[tableViewScope
] ]");
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 thetableViewScope
parameter. Since the entire table view tree might not be included, this is known as a partial command, andsm_tm_command
setsTM_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, andsm_tm_command
setsTM_FULL
to 1.tableViewScope
- One of the following parameters, which must be preceded by a table view name.
TV_AND_BELOW
which applies the command to the specified table view and all table views below it on the tree. If no parameter is specified, the transaction manager acts as thoughTV_AND_BELOW
was supplied.
BELOW_TV
which applies the command to the table views below the specified table view.
TV_ONLY
which applies the command to the specified table view only.
SV_ONLY
which applies the command only to the table views of the specified server view.
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:
- The transaction manager checks to see that the mode is not initial or view.
- For engines requiring it, the transaction model starts a database transaction.
- 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.
- 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 tosave_button
. By default,save_button
is active in new and update modes.
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.
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 explicitDBMS 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.
The following request events can be generated by the
SAVE
command:
TM_PRE_SAVE