ADVANCED DB2:
Overview:
This
module enables the student to understand the concept of Advanced DB2.
Outline:
Topics
covered,
a. Data Base Constraints
b. Journaling
c. Commitment Control
d.
Triggers
Objective:
By the end of this module, the student should be able
to:
- Understanding concept of
Data Base Constraints
- Understanding concept of
Journaling
- Understanding concept of
Commitment Control
- Understanding concept of
Triggers
Commitment Control
To use commitment control,
you do the following:
· Use
the CL commands CRTJRNRCV (Create Journal Receiver) CRTJRN
(Create Journal) and STRJRNPF (Journal Physical File) to prepare for
using commitment control, and the CL commands STRCCMTCTL (Start
Commitment Control) and ENDCMTCTL (End Commitment Control to notify the system
when you want to start and end commitment control. See the CL Reference for
information on these commands.
· Specify
commitment control on the file-description specifications of the files you want
under commitment control.
· Use
the COMIT (Commit) Operation code to apply a group of changes top files
under commitment control or use the ROLBK (Roll Back) operation code to
eliminate the pending group of changes top files under commitment control.
Specifying Files for
Commitment Control
On the file-continuation
specifications enter a K in position 53 and the word COMIT in positions 54
through 59. On the file description specifications described the file as having
device DISK in positions 40 through 46.
When a program specifies
commitment control for a file the specification applies only to the input and
output operations made by this program for this file commitment control does
not have apply to operations other than input and output operations. It does
not apply to files that do not have commitment control specified in the program
doing the input output operation.
Commitment Control
Operations
The COMIT (Commit)
operation tells the system that you have completed a group of changes to the
files under commitment control. The ROLBK (Roll Back) operation eliminates the
current group of changes to the files under commitment control.
If the system fails it
implicitly issues ROLBK operation, You can check the identity of last
successfully completed group of changes using the label you specify in factors
of the COMIT operation code, and the notify object you specify on the STRCMTCTR
command.
At the end of routing
step, or when you issue the ENDCMTTCTL command the OS/400 system issues an
implicit ROLBK. which eliminates any changes since the last ROLBK or COMIT operation
that you issued. To ensure that all your file operations have effect issue a
COMIT operation before ending a routing step operation under commitment
control.
Commitment Control in the
Program Cycle
Commitment Control is intended for full
procedural files, where the input and output is under your control. Do not use
commitment control with primary and secondary files, where input and output is
under the control of the RPG/400 program cycle. The following are some of the
reasons for this recommendation.
- You cannot issue a COMIT operation for the last total output in
your program.
- It is difficult to program within the cycle for recovery from a
locked record condition.
- Level indicators are not reset by the ROLBK operation.
- After A ROLBK operations processing matching records may
produce a sequence error.
Example of
Using-Commitment Control
The following is an example of the
specifications and CL command for a program operating under commitment control.
To prepare for using commitment control you issue the following.
CL commands
CRTJRNRCV
JRNRCV (RECEIVER)
The above command creates
a journal receiver named RECEIVER
CRTJRN
JRN (JOURNAL) JRNRCV (RECEIVER)
The
above command creates a journal named JOURNAL and attaches the journal receiver
named RECEIVER.
STRJRNPF FILE (MASTER) JRN
(JOURNAL)
The
above command directs journal entries for the files MASTER to the JOURNAL. In
your program you specify COMIT for the file MASTER.
FMASTER UF E K DISK KCOMIT
In
the calculation specifications, use the COMIT operation to complete a group of
operations.
KEY CHAINMASTER 50
N50 UPDATRECORD 99
N99 COMIT
If
an operation within a group fails, use the ROLER operation to eliminate the
entire group o foperations.
99
ROLBK
Example of Using
Commitment Control
To
operate your program (named REVISE) under commitment control you issue the
commands:
STRCMTCTLLCKLVL(*ALL)
The above command starts
commitment control with the higher level of locking
CALL REVISE
The
above command calls your program (named REVISE).
ENDCMTCTL
The
above command ends commitment control and causes implicit Roll Back operation.
No comments:
Post a Comment