title: PL/SQL: re-write SELECT statement using IN parameter in stored procedure
body: <p>Suppose I have an Oracle 11.2 database containing the following table:</p>
  
  <pre><code>TABLE: SURVEY
  
  PARAMETER    MALE   FEMALE 
  --------------------------
  SAMPLE_SIZE  102       95
  AVG_WEIGHT   170      120
  AVG_HEIGHT   5.9      5.4
  </code></pre>
  
  <p>Here's an example minimal PL/SQL stored procedure that selects the average weight of males and places it (e.g. 170) into variable <code>v_stat</code>.  </p>
  
  <pre><code>PROCEDURE get_stat (gender IN VARCHAR2) 
  AS
      v_stat number;
  BEGIN
      SELECT male INTO v_stat FROM survey WHERE parameter = 'avg_weight';
  END get_stat;
  </code></pre>
  
  <p>Notice the IN parameter <code>gender</code> doesn't do anything here. What I want is to pass in variable <code>gender</code>, which may equal either 'male' or 'female', and use <code>gender</code> somehow in the SELECT statement (instead of 'male'). The goal is to pass in <code>gender</code> as a variable that may be used to return, for example, the average weight of, either male or female, as defined by <code>gender</code>. </p>
  
  <p>I know I can probably use an IF/THEN/ELSE statement with two separate SELECT statements, but I wondered if there was an elegant way to use just one SELECT statement by changing 'male' in the above SELECT statement to something else?</p>
  
  <p>Note that this is a re-do of my previous question here </p>
  
  <p><a href="https://stackoverflow.com/questions/9957984/how-to-programmatically-set-table-name-in-pl-sql">How to programmatically set table name in PL/SQL?</a></p>
  
  <p>that was (rightly) criticized for not being a realistic question. </p>