Good afternoon,
We are refactoring a legacy COBOL batch program that processes customer adjustments row by row. The current design opens a cursor, fetches one row, updates a status column, and issues a COMMIT after each successful update.
The SQL declaration in the program is structured as follows:
sql
DECLARE CUST_ADJ CURSOR WITH HOLD FOR
SELECT CUST_ID, ADJ_AMT, ADJ_STATUS
FROM BILLING.ADJUSTMENTS
WHERE ADJ_STATUS = 'PENDING'
FOR UPDATE OF ADJ_STATUS
After the first COMMIT, the next FETCH returns SQLCODE +100 even though additional qualifying rows remain. The DB2 manual states:
Could someone clarify whether WITH HOLD is appropriate in this scenario, or whether we should redesign to process in chunks without intermediate commits?A WITH HOLD cursor remains open across COMMIT points when the application explicitly commits work.
Thank you,
Elena