title: Conditionally define a Cursor
body: <p>I have a Procedure in Oracle that takes a <code>varchar2</code> paramater.  Based on the value of that parameter, I need to define a cursor.  The cursor will operate on different tables based on the value of the parameter.  </p>
  
  <p>I wanted to do something like below but it throws an error in the <code>CURSOR</code> definition piece of code.  Any ideas?</p>
  
  <pre><code>PROCEDURE GET_RECORDS(v_action IN VARCHAR2)
  IS
  CURSOR get_records
  IS
         IF(v_action = 'DO THIS') THEN
             SELECT * from &lt;THIS&gt;;
         ELSE
             SELECT * from &lt;THAT&gt;;
         END IF;
  BEGIN
         OPEN get_records;
  
         FETCH get_records
         INTO v_thing;
  
         v_loop := 0;
         WHILE get_records%FOUND
         LOOP
  
             FETCH get_records
             INTO v_thing;
  
         END LOOP;
         CLOSE get_records;
  END;
  </code></pre>