I am passing a value based on a value retrieve from another cursor. The cursor where the value is passed to always retrieves the same number of rows, basically it just returns the value from just one variable.
For example, cursor cur_prog always displays the first value returned from cursor cur_progs. I display cursor cur_progrs to make sure I am fetching all the rows and it is. Can I not change my variable C_MONTHS to change and fetch again?
For example, cursor cur_prog always displays the first value returned from cursor cur_progs. I display cursor cur_progrs to make sure I am fetching all the rows and it is. Can I not change my variable C_MONTHS to change and fetch again?
Code:
cursor cur_progs is
SELECT DISTINCT FISCAL_MO
FROM TABLE1
ORDER BY FISCAL_MO;
cursor cur_prog is
SELECT COUNT(*)
FROM TABLE2
WHERE FISCAL_MONTHS = C_MONTHS;
------Declaring procedure names
PROCEDURE A_UPDATE_PROG;
--========================================================
-- PROCEDURE AND SQL STATEMENTS
--========================================================
PROCEDURE A_UPDATE_PROG IS
BEGIN
dbms_output.put_line('COUNTING PROGRAMS ');
C_CTR := 0;
OPEN cur_progS;
FETCH cur_progs INTO C_MONTHS;
OPEN cur_prog;
LOOP
FETCH cur_prog INTO C_CTR;
FETCH cur_progs INTO C_MONTHS;
EXIT WHEN C_MONTHs='09';
dbms_output.put_line('Next Months: ' ||C_MONTHS);
END LOOP;