title: syntax error: unexpected end of file
body: <p>I have an SQL query that when it is put in to a function it stops working with this <code>syntax error: unexpected end of file</code> error message. Removing it from a function causes it to start working again.</p>
  
  <p>Why is this?</p>
  
  <pre><code>function pull_data
  {
      sqlplus -s $user/$pass@$db &lt;&lt; EOF
      SELECT DISTINCT order_number,
                      order_total_items,
                      order_total_value
      FROM orders
  
      WHERE order_date BETWEEN '$1' AND '$2';
  
      exit;
  
      EOF
  }
  </code></pre>