I have 2 static cursors, WITHOUT_UNITS_CUR and WITH_UNITS_CUR. Depending on the variable, V_INCLUDE_UNITS, I want to use one or the other. Currently, I am using an if statement everytime I need to reference one of the cursors. For example:
What I'd love to be able to do is assign a 3rd cursor to one of them once, and then use that 3rd cursor instead of constantly repeating the if-else block. For example:
Is that possible?
Code:
IF V_INCLUDE_UNITS = 0 THEN
OPEN WITHOUT_UNITS_CUR ;
FETCH WITHOUT_UNITS_CUR INTO V_NIMANU , V_NIMASE , V_NINACD , V_NINUCD ;
ELSE
OPEN WITH_UNITS_CUR ;
FETCH WITH_UNITS_CUR INTO V_NIMANU , V_NIMASE , V_NINACD , V_NINUCD ;
END IF ;
Code:
IF V_INCLUDE_UNITS = 0 THEN
MY_CUR = WITHOUT_UNITS_CUR ;
ELSE
MY_CUR = WITH_UNITS_CUR ;
END IF ;
OPEN MY_CUR ;
FETCH MY_CUR INTO V_NIMANU , V_NIMASE , V_NINACD , V_NINUCD ;