IBM AS/400 Frozen Dessert Maker User Manual


 
Using Commitment Control
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++
FMASTER UF E K DISK COMMIT
FTRANS UF E K DISK COMMIT
F*
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
C :
C :
*
* Use the COMMIT operation to complete a group of operations if
* they were successful or rollback the changes if they were not
* successful.
*
C UPDATE MAST_REC 90
C UPDATE TRAN_REC 91
C IF *IN90 OR *IN91
C ROLBK
C ELSE
C COMMIT
C ENDIF
Figure 155. Example of Using Commitment Control
To operate your program (named REVISE) under commitment control, you issue
the commands:
1.STRCMTCTL LCKLVL(*ALL)
This command starts commitment control with the highest level of locking.
2.CALL REVISE
This command calls the program REVISE.
3.ENDCMTCTL
This command ends commitment control and causes an implicit Roll Back oper-
ation.
Specifying Conditional Commitment Control
You can write a program so that the decision to open a file under commitment
control is made at run time. By implementing conditional commitment control, you
can avoid writing and maintaining two versions of the same program: one which
operates under commitment control, and one which does not.
The COMMIT keyword has an optional parameter which allows you to specify con-
ditional commitment control. You enter the COMMIT keyword in the keyword
section of the file description specifications for the file(s) in question. The ILE RPG
compiler implicitly defines a one-byte character field with the same name as the
one specified as the parameter. If the parameter is set to '1', the file will run under
commitment control.
The COMMIT keyword parameter must be set prior to opening the file. You can set
the parameter by passing in a value when you call the program or by explicitly
setting it to '1' in the program.
For shared opens, if the file in question is already open, the COMMIT keyword
parameter has no effect, even if it is set to '1'.
Chapter 16. Accessing Database Files 311