title: PL/SQL Cursor Use Parameter As A Column Name
body: <p>I am working with PL/SQL. I am sending some parameters to my procedure. One of these parameters should be a column name. Initially it's a varchar2, but I want to use this in my cursor to reference a column name. How is this possible?</p>
  
  <p>This is what my code looks something like:</p>
  
  <pre><code>    PROCEDURE proc_name( x IN VARCHAR2, y IN VARCHAR2 ) IS
  
        cursor csr IS 
         SELECT * 
         FROM table
         SORT BY x y
  
  
       BEGIN 
        for y in csr loop 
          ------
        end loop; 
  
       END proc_name;
  </code></pre>
  
  <p>I've tried to research this for the last couple of days with no luck. I looked into dynamic SQL, is this the right direction? Doesn't seem to be working for me.</p>
  
  <p>Thanks in advance for any help</p>