title: switch between two cursors based on parameter passed into stored procedure
body: <p>I have two cursors in my procedure that only differ on the table name that they join to.
  The cursor that is used is determined by a parameter passed into the procedure</p>
  
  <pre><code>if (param = 'A') then
      DECLARE CURSOR myCursor IS 
      SELECT x,y,z
      FROM table1 a, table2 b
  
      BEGIN
         FOR  aRecord in myCursor
         LOOP
            proc2(aRecord.x, aRecord.y, aRecord.z);       
         END LOOP;
         COMMIT;
      END;
  
  elsif (param = 'B') then
      DECLARE CURSOR myCursor IS 
      SELECT x,y,z
      FROM table1 a, table3 b  -- different table
  
      BEGIN
         FOR  aRecord in myCursor
         LOOP
            proc2(aRecord.x, aRecord.y, aRecord.z);       
         END LOOP;
         COMMIT;
      END;
  end if
  </code></pre>
  
  <p>I don't want to repeat the code for the sake of one different table.
  Any suggestions on how to improve this?</p>
  
  <p>Thanks in advance</p>