title: PL/SQL - How to create a conditional cursor?
body: <p>I need to have a <strong>conditional cursor</strong>, like:</p>
  
  <ul>
  <li>If a row exists (using <strong>WHEN EXISTS</strong> or something like this), then my cursor is:
  <ul>
  <li>CURSOR varCursor IS SELECT 1 a FROM DUAL;</li>
  </ul></li>
  <li>Else
  <ul>
  <li>CURSOR varCursor IS SELECT 2 a FROM DUAL;</li>
  </ul></li>
  </ul>
  
  <p>But look, I don't want to change a column result, I want to change the entire cursor.</p>
  
  <p>Bellow I put a bigger example.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>See:</p>
  
  <pre><code>SET serveroutput ON SIZE 900000;
  DECLARE
    CURSOR varCursor IS SELECT 1 a FROM DUAL;
    -- CURSOR varCursor IS SELECT 2 a FROM DUAL;
  BEGIN
    FOR varRow IN varCursor LOOP
      dbms_output.put_line('row: ' || varRow.a);
    END LOOP;
    dbms_output.put_line('Done.');  
  END;
  </code></pre>