While defining a program with EGL, you can specify explicit logic to issue commits and rollbacks for both IBM i native database files (containing relative, serial, and indexed records) and SQL tables. This logic consists of calls to the sysLib.commit() and sysLib.rollback() system functions. You can also set the converseVar.commitOnConverse system variable to 1, which causes changes to be committed when any converse statement presents a form to the user.
Any explicit use of commitment control ends the current unit of recovery and begins another. Commitment Control services releases any record and file locks being held when changes are committed or rolled back.
At certain times, EGL automatically performs commitment control. This implicit commitment control is independent of any instances of explicit commitment control. As you design your programs, you can exploit implicit commitment control and avoid using explicit commitment control. The following table summarizes the implicit commitment control processing that EGL does.
| Cause of program exit | Implicit action | Main program | Called program |
|---|---|---|---|
| transfer to transaction or show | sysLib.commit() | yes | N/A |
| SQL CLOSE CURSOR | yes | N/A | |
| transfer to program | sysLib.commit() | no | N/A |
| SQL CLOSE CURSOR | yes | N/A | |
| exit program | sysLib.commit() | yes | no |
| SQL CLOSE CURSOR | yes | If the program started the run unit, yes | |
| error | sysLib.rollback() | yes | no |
| SQL CLOSE CURSOR | yes | If the program started the run unit, yes |