title: SELECT-ing data from stored procedures
body: <p>I have a complicated <code>SELECT</code> query that filters on a time range, and I want this time range (start and end dates) to be specifiable using user-supplied parameters.  So I can use a stored procedure to do this, and the return is a multiple-row result set.  The problem I'm having is how to deal with this result set afterwards.  I can't do something like:</p>
  
  <pre><code>SELECT * FROM (CALL stored_procedure(start_time, end_time))
  </code></pre>
  
  <p>even though the stored procedure is just a <code>SELECT</code> that takes parameters.  Server-side prepared statement also don't work (and they're not persistent either).
  Some suggest using temporary tables; the reason that's not an ideal solution is that 1) I don't want to specify the table schema and it seems that you have to, and 2) the lifetime of the temporary table would only be limited to a invocation of the query, it doesn't need to persist beyond that.</p>
  
  <p>So to recap, I want something like a persistent prepared statement server-side, whose return is a result set that MySQL can manipulate as if it was a subquery.  Any ideas?  Thanks.</p>
  
  <p>By the way, I'm using MySQL 5.0.  I know it's a pretty old version, but this feature doesn't seem to exist in any more recent version.  I'm not sure whether SELECT-ing from a stored procedure is possible in other SQL engines; switching is not an option at the moment, but I'd like to know whether it's possible anyway, in case we decide to switch in the future.</p>