If the resource is recoverable (as in the case of an SQL database), the forUpdate option locks the record so that it cannot be changed by other programs until a commit occurs. For details on commit processing, see Logical unit of work.
An example of file access is as follows:
try open record1 forUpdate; onException myErrorHandler(8); return; end try get next record1; onException myErrorHandler(12); return; end while (record1 not endOfFile) makeChanges(record1); // process the record try replace record1; onException myErrorHandler(16); return; end try get next record1; onException myErrorHandler(12); return; end end // end while sysLib.commit();
Details on the get next statement depends on the record type. For details on SQL processing, see SQL processing.
1, 2, 2, 2, 3, 4
Each of the following tables illustrates the effect of running a sequence of EGL statements on the same indexed record.
The next two tables apply to EGL-generated COBOL code.
EGL statement (in order) | Key in the indexed record | Key in the file record retrieved by the statement | EGL error value for COBOL |
---|---|---|---|
get | 2 | 2 (the first of three) | duplicate |
get next | any | 3 | — |
EGL statement (in order) | Key in the indexed record | Key in the file record retrieved by the statement | EGL error value for COBOL |
---|---|---|---|
set (of the form set record position) | 2 | no retrieval | duplicate |
get next | any | 2 (the first of three) | duplicate |
get next | any | 2 (the second) | duplicate |
get next | any | 2 (the third) | — |
get next | any | 3 | — |
The next two tables apply to EGL-generated Java™ code.
EGL statement (in order) | Key in the indexed record | Key in the file record retrieved by the statement | EGL error value for Java |
---|---|---|---|
get | 2 | 2 (the first of three) | duplicate |
get next | any | 2 (the second) | duplicate |
get next | any | 2 (the third) | — |
get next | any | 3 | — |
EGL statement (in order) | Key in the indexed record | Key in the file record retrieved by the statement | EGL error value for Java |
---|---|---|---|
set (of the form set record position) | 2 | no retrieval | duplicate |
get next | any | 2 (the first of three) | — |
get next | any | 2 (the second) | duplicate |
get next | any | 2 (the third) | — |
get next | any | 3 | — |
When a get next operates on a MQ record, the first record in the queue is read into the MQ record. This placement occurs because the get next invokes one or more MQSeries® calls:
On CICS® for z/OS®, a single program cannot include the combination of add statement and get next statement for the same spool file. This restriction also applies when the get next and add statements are in different programs, and one program calls the other.
An SQL FETCH statement represents the EGL get next statement in the generated code. The format of the generated SQL statement cannot be changed, except to set the INTO clause.
Finally, when you specify SQL COMMIT or sysLib.commit, your code retains position in the cursor that was declared in the open statement, but only if you use the hold option in the open statement.
Related concepts
DL/I database support
Record types and properties
resultSetID
SQL support
Related tasks
Syntax diagram for EGL statements and commands
Related reference
#dli directive
add
CICS-related considerations
close
delete
Exception handling
execute
get
get next inParent
get previous
I/O error values
EGL statements
open
prepare
replace
set