Count number of rows in a cursor
Posted on 2007-10-05
I am new to Procedures and cursors, so would appreciate some advice on this.
In the following Procedure, the Select of the Cursor can return one or more rows.
CREATE OR REPLACE PROCEDURE COMPUTE_DELAY
( P_STEP_ID IN BPM_DEF_STEPS.ID%TYPE)
CURSOR c_get_parent(pSTEP_ID BPM_DEF_STEPS.ID%TYPE) IS
PREDSTEP.ID = COND.STEP_ID
AND COND.ID = TRANS.STEP_CONDITION_ID
AND TRANS.NEXT_STEP_ID = SUCCSTEP.ID
AND SUCCSTEP.ID = pSTEP_ID
FETCH c_get_parent INTO
xPRED_ID, -- xPred_ID = ID of PRED
xSUCC_ID; -- xSucc_ID = ID of SUCC
Within the main Loop, I need to know how many rows were returned by the Select. I know that c_get_parent%ROWCOUNT after Fetch, can tell how many rows have been retrieved so far, but I need to know how to determine the total number of rows in c_get_parent before I proceed with the next statements.