title: How to increase performance by declaring Cursor on need basis in PL SQL?
body: <p>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.</p>
  
  <p>Existing code :</p>
  
  <pre><code>Function MyFunction(Param1 IN DATE) RETURN BOOLEAN
  
  CURSOR C1 IS &lt;MyTimeConsumingQuery1&gt;;
  
  CURSOR C2 IS &lt;MyTimeConsumingQuery2&gt;;
  
  IF NVL(KnownCondition,'Y') = 'N' THEN
    OPEN C1;
  
  ELSE
   OPEN C2;
  
  END IF; 
  
  ...
  END MyFunction
  </code></pre>
  
  <p>Below is what I am trying to achieve:</p>
  
  <pre><code>Function MyFunction(Param1 IN DATE) RETURN BOOLEAN
  
  IF NVL(KnownCondition,'Y') = 'N' THEN
  
  CURSOR C1 IS &lt;MyTimeConsumingQuery1&gt;;
  
    OPEN C1;
  
  ELSE
  
  CURSOR C2 IS &lt;MyTimeConsumingQuery2&gt;;
  
   OPEN C2;
  
  END IF; 
  
  ...
  END MyFunction
  </code></pre>
  
  <p>When I try to compile the code, I am getting <code>PLS-00103: Encountered the symbol</code> error.</p>
  
  <p>How can I selectively invoke the cursor query to increase the performace?</p>