title: How to programmatically set table name in PL/SQL?
body: <p>I created the following simple PL/SQL stored procedure example to ask a specific question. This procedure inserts an employee name and id number into a table called <code>employees_???</code>. The ??? is explained below.</p>
  
  <pre><code>PROCEDURE hire_employee (emp_id IN INTEGER, name IN VARCHAR2, country IN VARCHAR2) 
  AS
  BEGIN
      INSERT INTO employees_??? VALUES (emp_id, name, 1000);
  END hire_employee;
  </code></pre>
  
  <p>What I need is to set the table name based on the IN variable <code>country</code>. For example,</p>
  
  <p>If country = 'usa', I want the INSERT line to read:</p>
  
  <pre><code>INSERT INTO employees_usa VALUES (emp_id, name, 1000);
  </code></pre>
  
  <p>If country = 'germany', I want the INSERT line to read:</p>
  
  <pre><code>INSERT INTO employees_germany VALUES (emp_id, name, 1000);
  </code></pre>
  
  <p>If country = 'france', I want the INSERT line to read:</p>
  
  <pre><code>INSERT INTO employees_france VALUES (emp_id, name, 1000);
  </code></pre>
  
  <p>etc...</p>
  
  <p>Is there a way to do this in PL/SQL by substituting something in place of <code>employee_???</code> so only one line of code for INSERT is used? Or is using a <code>case</code> or <code>if/then/else</code> statement the best way?</p>