One of our production COBOL/DB2 program has coding like this:
INITIALIZATION.
.
.
.
PERFORM S0100-SYSIN-PROCESS.
PERFORM S200-OPEN-FIRST-CURSOR.
PERFORM S201-FETCH-FIRST-CURSOR.
MAINLINE.
PERFORM S100-DATA-PROCESS
UNTIL S-NO-MORE-ROWS
PERFORM S201-CLOSE-FIRST-CURSOR.
.
.
.
S100-DATA-PROCESS.
PERFORM S210-UPDATE-ORDER.
PERFORM S201-FETCH-FIRST-CURSOR.
.
.
.
PERFORM S0100-SYSIN-PROCESS.
PERFORM S200-OPEN-FIRST-CURSOR.
PERFORM S201-FETCH-FIRST-CURSOR.
MAINLINE.
PERFORM S100-DATA-PROCESS
UNTIL S-NO-MORE-ROWS
PERFORM S201-CLOSE-FIRST-CURSOR.
.
.
.
S100-DATA-PROCESS.
PERFORM S210-UPDATE-ORDER.
PERFORM S201-FETCH-FIRST-CURSOR.
The code in the INITIALIZATION para opens the cusor then does a FETCH. The INITIALIZATION is followed by MAINLINE para where S100- & S201- paras are executed. In S100-, we have another UPDATE followed by FETCH. I am not able to understand how this can be possible to open, fetch, update and fetch can run successfully !? I understand the cursor concept like after declare there should be a OPEN, FETCH and CLOSE but here the cursor is OPENed, FETCHed and goes to UPDATE para and again FETCH. Would somebody please explain me because of this any records are skipped or it is ok?
Thanks a lot.
Bye.