I basically want to know if you can re-use a cursor? If you do you need to close the cursor then re-open it or can you just run the fetch part again.
In working storage i have array/table.
01 WS_TABLE.
05 EMP_NUM X(5)OCCURS 10 TIMES.
05 NAME OCCURS 10 TIMES.
05 EMP_NUM X(5)OCCURS 10 TIMES.
05 NAME OCCURS 10 TIMES.
Here is the cursor set up
EXEC SQL DECLARE C1 CURSOR WITH ROWSET POSITIONING FOR
SELECT NAME, EMP-NUM
FROM CORPORATE.EMPLOYEE
WHERE DEPT = :WS-DEPT
END-EXEC.
EXEC SQL OPEN C1 END-EXEC.
EXEC SQL FETCH FIRST ROWSET FROM C1 FOR 10 ROWS INTO :NAME, :EMP-NUM END-EXEC.
EXEC SQL CLOSE C1 END-EXEC.
SELECT NAME, EMP-NUM
FROM CORPORATE.EMPLOYEE
WHERE DEPT = :WS-DEPT
END-EXEC.
EXEC SQL OPEN C1 END-EXEC.
EXEC SQL FETCH FIRST ROWSET FROM C1 FOR 10 ROWS INTO :NAME, :EMP-NUM END-EXEC.
EXEC SQL CLOSE C1 END-EXEC.
I want to run it for when WS-DEPT is set to '010' and then run it again for when WS-DEPT is set to '020'. Can this be done using one cursor?
Many thanks
DB