I have the below code with 2 cursors. Both are time consuming ones even after required tuning. So, my idea is to increase performace of the function by invoking the cursor SQL only on need basis based on some known condition.
Existing code :
Function MyFunction(Param1 IN DATE) RETURN BOOLEAN
CURSOR C1 IS <MyTimeConsumingQuery1>;
CURSOR C2 IS <MyTimeConsumingQuery2>;
IF NVL(KnownCondition,'Y') = 'N' THEN
OPEN C1;
ELSE
OPEN C2;
END IF;
...
END MyFunction
Below is what I am trying to achieve:
Function MyFunction(Param1 IN DATE) RETURN BOOLEAN
IF NVL(KnownCondition,'Y') = 'N' THEN
CURSOR C1 IS <MyTimeConsumingQuery1>;
OPEN C1;
ELSE
CURSOR C2 IS <MyTimeConsumingQuery2>;
OPEN C2;
END IF;
...
END MyFunction
When I try to compile the code, I am getting PLS-00103: Encountered the symbol
error.
How can I selectively invoke the cursor query to increase the performace?