Db2-related considerations when changing data in a File Manager/Db2 Edit session
- The Edit session ends when END is pressed.
- The Edit session ends when CANCEL is pressed.
- A Db2® commit point is issued as part of a File Manager/Db2 SAVE primary command.
- A Db2® commit point is issued automatically because the number of successful changes reached the Auto-commit count value specified on the Editor Options (6 of 8) panel.
Within a File Manager/Db2 Edit session, multiple changes can be made to the data; you can send these changes to Db2® for validation with the SAVE primary command. At any time, the changes can be backed out (rolled back) to the state the data was in at the start of the Edit session, as long as a Db2® commit point has not been issued. This is unlike an the edit of a data set where typically, once changes have been saved, it is not possible to return to an earlier version of the data.
Changes made during a File Manager/Db2 Edit session are processed one row at a time. This is unlike the edit of a data set where, typically all of the changes made are written all together to the data set when the data is saved and the existing data set is completely replaced by the new one.
Changes made to the data in a Db2® object are validated by Db2® prior to the changes being accepted by Db2®. This is unlike changes that can be made to a data set, where typically there is no validation of the data and issuing a SAVE or END primary command is certain to save any pending changes.
- Inappropriate values for the data type of a column. For example, entering non-numeric data in a numeric column, or numeric data that is out of range in a numeric column.
- Violation of any check constraints applying to the Db2® object. For example, a column defined as CHAR(1) used to store the gender of a person, constrained to accept a value of only "M" or "F".
- Violation of any referential integrity rules applying to the Db2® object. For example, attempting to delete a primary key for which there are dependent rows in another table, and the DELETE rule for the constraint is RESTRICT
- Attempts to insert a duplicate with respect to a unique index defined on the Db2® object.
- Issue an explicit SAVE primary command.
- Press the Enter key with no other pending changes (the auto save feature). (See the Save data option on Editor Options (6 of 8) panel.)
- Press the END key (normally PF3) to end the Edit session. ( See Ending a File Manager/Db2 editor session.)
When you issue a SAVE primary command, any pending changes made are processed one row at a time. Each change results in a single INSERT, UPDATE, or DELETE SQL statement. If the change is unsuccessful, FM/Db2 marks the row in error in the Edit session. You must then correct the error before you can complete (commit) the data changes to Db2®.
FM/Db2 may issue Db2® commit points automatically during the SAVE process, if a non-zero value has been specified for the Auto-commit count, specified on the Editor Options (6 of 8) panel. Such commit points are issued whenever there have been the specified number of successful changes; it is possible for multiple commit points to be issued during the SAVE process. The commit points are issued regardless of whether errors are encountered when processing other rows.
At the end of the SAVE process, FM/Db2 may also issue an explicit Db2® commit, depending on the setting of the Commit when save issued and Commit when no save errors options. (See Editor Options (6 of 8) panel.)
Usage note: When processing a Db2® object that is subject to constraints, frequent validation of any changes made can avoid frustration at the end of the editor session (when PF3 is pressed). You can issue the SAVE command repeatedly during an Edit session to validate the changes just made, while retaining the ability to cancel the entire Edit session. Remember that, until a Db2® commit point is issued, the entire unit of work can be rolled back. In "normal mode", you also have the option to auto-commit changes when you issue a SAVE primary command. This option is disabled in "large mode".
Related references