Hi All,
This is regarding restarting a Cursor in a batch environment(Cobol).
We have a set of cursors used for data processing. We are using the cursors to fetch the data from the table and store in a local varaible.
we donot use any update or insert in cursors.
problem: When the cursor is getting an Sqlcode -911(deadlock) all the opened cursors are closing and the job is abending with Sqlcode -501.
To avoid this we have written a restart logic like
WHEN SQLCODE = -501
MOVE DFC-SQL-RETRY TO DFC-SAVE-RETRY
ADD DFC-Z50040-READ TO DFC-Z50040-SKIP
PERFORM Z50040-SETUP-LCCNSEL-CURSOR
SET PF-END-OF-LCCNSEL-NOT TO TRUE
MOVE DFC-SAVE-RETRY TO DFC-SQL-RETRY
but this restart was creating duplicate records in the file.
the cursor structure is as follows:
Cursor1(fetch a part number) --> Cursor 2 (get order details of the part) --> Cursor 3(get time details)--> Cursor 4.... etc.
Cursor 1 will be closed only after all eligible parts are processed.
if in the middle the cursor is closed the cursor 1 fetching the starting part which resulting the duplicating of output records.
Can some one please help me to avoid this duplication while restarting a cursor.
i look forward for your response.